Dashboards & Visualizations

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

HeinzWaescher
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

niketn
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

niketn
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!!!"
0 Karma

HeinzWaescher
Motivator

Very helpful, thanks 🙂

0 Karma

niketn
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!!!"

HeinzWaescher
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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...