Dashboards & Visualizations

Is it possible to unset drilldown tokens when global inputs change?

Motivator

Hi,

I have a form with several global inputs. Submitting these inputs will start "Panel A" to create a table.
By clicking a row in "Panel A" a drilldown will start "Panel B" using the global inputs and the drilldown token.

I would like to clean the results of "Panel B" when one the global inputs changes (the submit button is clicked). Is this possible?

Thanks in advance

0 Karma
1 Solution

Legend

@HeinzWaescher, Following is a run anywhere example based on your needs. Form inputs unset the tokens set in Panel 1 table drilldown.

  <fieldset submitButton="false">
    <input type="dropdown" token="field1">
      <label>field1</label>
      <choice value="abc">ABC</choice>
      <choice value="def">DEF</choice>
      <change>
        <unset token="tokPanel1_1"></unset>
        <unset token="tokPanel1_2"></unset>
      </change>
    </input>
    <input type="dropdown" token="field2">
      <label>field2</label>
      <choice value="ghi">GHI</choice>
      <choice value="jkl">JKL</choice>
      <change>
        <unset token="tokPanel1_1"></unset>
        <unset token="tokPanel1_2"></unset>
      </change>      
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
          | eval field1="$field1$"
          | eval field2="$field2$"
          </query>
        </search>
        <drilldown>
          <set token="tokPanel1_1">$row.field1$</set>
          <set token="tokPanel1_2">$row.field2$</set>
        </drilldown>
      </table>
    </panel>
    <panel depends="$tokPanel1_1$,$tokPanel1_2$">
      <table>
        <search>
          <query>| makeresults
          | eval field1="$tokPanel1_1$"
          | eval field2="$tokPanel1_2$"
          </query>
        </search>
      </table>  
    </panel>    
  </row>

Hope this is helpful.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

Legend

@HeinzWaescher, Following is a run anywhere example based on your needs. Form inputs unset the tokens set in Panel 1 table drilldown.

  <fieldset submitButton="false">
    <input type="dropdown" token="field1">
      <label>field1</label>
      <choice value="abc">ABC</choice>
      <choice value="def">DEF</choice>
      <change>
        <unset token="tokPanel1_1"></unset>
        <unset token="tokPanel1_2"></unset>
      </change>
    </input>
    <input type="dropdown" token="field2">
      <label>field2</label>
      <choice value="ghi">GHI</choice>
      <choice value="jkl">JKL</choice>
      <change>
        <unset token="tokPanel1_1"></unset>
        <unset token="tokPanel1_2"></unset>
      </change>      
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
          | eval field1="$field1$"
          | eval field2="$field2$"
          </query>
        </search>
        <drilldown>
          <set token="tokPanel1_1">$row.field1$</set>
          <set token="tokPanel1_2">$row.field2$</set>
        </drilldown>
      </table>
    </panel>
    <panel depends="$tokPanel1_1$,$tokPanel1_2$">
      <table>
        <search>
          <query>| makeresults
          | eval field1="$tokPanel1_1$"
          | eval field2="$tokPanel1_2$"
          </query>
        </search>
      </table>  
    </panel>    
  </row>

Hope this is helpful.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

Motivator

Very helpful, thanks 🙂

0 Karma

Legend

@HeinzWaescher, since you are using Submit button and not the Form Input's change events to submit the token values, you will have to use JavaScript to unset the tokens on submit() event of the Submit button.

  require([
    "splunkjs/mvc",
    "splunkjs/mvc/tokenutils",
    "splunkjs/mvc/simplexml/ready!"
     ], function(mvc,TokenUtils) {
       var submit= mvc.Components.get("submit");
       submit.on("submit", function() {
             // Access the "submitted" token model since your tokens are not being set on change
             var tokens = mvc.Components.get("submitted");

             // Unset Input Tokens like $mytoken1$ $mytoken2$ etc
             tokens.unset("mytoken1", "");
             tokens.unset("mytoken2", "");

             //required functionality of Submit button.
             submitTokens();
       });
 });

Make sure to include the required SplunkJS libraries (I might have missed as this is not tested, in fact TokenUtils might not be required).

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

Motivator

Thanks, I want to avoid JavaScript and I will try it out without the submit button approach and use the input's change.

0 Karma