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
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...