Dashboards & Visualizations

How to set and unset a drilldown token with 3 input token?

lnn2204
Path Finder

Hi all,

This is change condition in 3 inputs

 

 

 

      <change>
        <condition label="Any">
          <set token="flag_1">0</set>
        </condition>
        <condition>
          <set token="flag_1">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>
      <change>
        <condition label="Any">
          <set token="flag_2">0</set>
        </condition>
        <condition>
          <set token="flag_2">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>
      <change>
        <condition label="Any">
          <set token="flag_3">0</set>
        </condition>
        <condition>
          <set token="flag_3">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>

 

 

 

This is the drilldown token for setting "showDetails" to "true" to display another table:

 

 

 

        <drilldown>
          <condition field="RuleID">
            <set token="form.ruleID_tok">$click.value2$</set>
            <set token="flag_1">1</set>
            <set token="showDetails">true</set>
          </condition>
          <condition field="RuleDescription">
            <set token="form.ruleDescription_tok">$click.value2$</set>
            <set token="flag_2">1</set>
            <set token="showDetails">true</set>
          </condition>
          <condition field="RuleLevel">
            <set token="form.ruleLevel_tok">$click.value2$</set>
            <set token="flag_3">1</set>
            <set token="showDetails">true</set>
          </condition>
        </drilldown>

 

 

 

And now, I want to unset showDetails when (flag_1, flag_2, flag_3) = 0. To hide the table depends on showDetails token.

Labels (3)
0 Karma
1 Solution

lnn2204
Path Finder

Thank you, but I don't know how to use  it. Btw, I solved the problem with ton of logic <done> and <condition> tag.

View solution in original post

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@lnn2204 - I think in this case you need to use JavaScript.

require([
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
], function ($, mvc) {

    let submittedTokens = mvc.Components.getInstance('submitted');
    let defaultTokens = mvc.Components.getInstance('default');

    function processShowDetails(){
        let flag_1 = submittedTokens.get("flag_1");
        let flag_2 = submittedTokens.get("flag_2");
        let flag_3 = submittedTokens.get("flag_3");

        if(flag_1=="0" && flag_2=="0" && flag_3=="0"){
              submittedTokens.unset("showDetails");
              defaultTokens.unset("showDetails");
        }
    }
    
    submittedTokens.on("change:flag_1", processShowDetails);
    submittedTokens.on("change:flag_2", processShowDetails);
    submittedTokens.on("change:flag_3", processShowDetails);
});

Kindly ignore typos.

 

I hope this helps!!!

lnn2204
Path Finder

Thank you, but I don't know how to use  it. Btw, I solved the problem with ton of logic <done> and <condition> tag.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@lnn2204 

Can you please share dashboard's  sample XML to get some idea about the inputs and the dependent panels. ? 

KV

0 Karma

lnn2204
Path Finder

This is the input

 

  <fieldset submitButton="false">
    <input type="time" token="allDashboard_time_tok" searchWhenChanged="true">
      <label>Time's Range</label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="dropdown" token="ruleID_tok" searchWhenChanged="true">
      <label>Rule's ID</label>
      <choice value="*">Any</choice>
      <fieldForLabel>RuleID</fieldForLabel>
      <fieldForValue>RuleID</fieldForValue>
      <search base="Base">
        <query>fields RuleID | top 0 RuleID |  sort + RuleID</query>
      </search>
      <default>*</default>
      <initialValue>*</initialValue>
      <change>
        <condition label="Any">
          <set token="flag_1">0</set>
        </condition>
        <condition>
          <set token="flag_1">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="ruleDescription_tok" searchWhenChanged="true">
      <label>Rule's Description</label>
      <choice value="*">Any</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <fieldForLabel>RuleDescription</fieldForLabel>
      <fieldForValue>RuleDescription</fieldForValue>
      <search base="Base">
        <query>fields RuleDescription | top 0 RuleDescription |  sort + RuleDescription</query>
      </search>
      <change>
        <condition label="Any">
          <set token="flag_2">0</set>
        </condition>
        <condition>
          <set token="flag_2">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="ruleLevel_tok" searchWhenChanged="true">
      <label>Rule's Level</label>
      <choice value="*">Any</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <fieldForLabel>RuleLevel</fieldForLabel>
      <fieldForValue>RuleLevel</fieldForValue>
      <search base="Base">
        <query>fields RuleLevel | top 0 RuleLevel | sort + RuleLevel</query>
      </search>
      <change>
        <condition label="Any">
          <set token="flag_3">0</set>
        </condition>
        <condition>
          <set token="flag_3">1</set>
          <set token="showDetails">true</set>
        </condition>
      </change>
    </input>
  </fieldset>

 

0 Karma
Get Updates on the Splunk Community!

Introducing New Splunkbase Governance!

Splunk apps are essential for maximizing the value of your Splunk Experience. Whether you’re using the default ...

Splunk Edge Processor | Popular Use Cases to Get Started with Edge Processor

Splunk Edge Processor offers more efficient, flexible data transformation – helping you reduce noise, control ...

3 Ways to Make OpenTelemetry Even Better

My role as an Observability Specialist at Splunk provides me with the opportunity to work with customers of ...