Dashboards & Visualizations

Multiselect to pass a token in Static value

DataOrg
Builder

I tried passing token value in multiselect from another results but it was not picking the token value. is there any turnaround option for this?

 <choice value="$Token$">All</choice>

this where i have to pass the token value

<input type="multiselect" token="env" searchWhenChanged="true">
    <label>Environment</label>
     <search>    <query>dedup environment</query>
    </search>
         <choice value="$Token$">All</choice>
    <fieldForLabel>environment</fieldForLabel>
    <fieldForValue>environment</fieldForValue>
      </input>
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@premranjithj

You can use token in search and populate dropdown.

<input type="multiselect" token="multiselect" id="multiselectId">
  <label>Multi Select</label>
  <delimiter> </delimiter>
  <fieldForLabel>environment</fieldForLabel>
  <fieldForValue>environment_value</fieldForValue>
  <search>
    <query>YOUR_SEARCH | dedup environment | table environment | eval environment_value=environment, a=1
      | append  [| makeresults | eval environment="$value$",environment_value="All", a=0] | sort a | table environment environment_value</query>
  </search>
</input>
0 Karma

DataOrg
Builder

@kamlesh_vaghela . I have JS to check All is selected other selection should be removed which is not working if its not a static value.
i was using the similar approach only but its not working with JS

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@premranjithj

You can make it dynamic by using search it self. You can assign your required values to $Token$ and use it in search. Can you share more information regarding $Token$ how you populate this token?

0 Karma

DataOrg
Builder

@kamlesh_vaghela i dont have problem is with generating token values . I have JS which is not working if ALL values are generated from search instead of all shps<>

I am using JS to check if "All values" are selected other options should be unselected which is not working

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@premranjithj
Can you please share your full JS?

0 Karma

DataOrg
Builder

@kamlesh_vaghela please test with dynamic results in multiselect.

 require([
     'underscore',
     'splunkjs/mvc',
     'splunkjs/mvc/simplexml/ready!'], function (_, mvc) {

 var multiselect = splunkjs.mvc.Components.getInstance("multiselectId");
 multiselect.on("change", function (value) {
     var defaulLabel="All Shops";
     if (value.length > 1 && ~(value.indexOf(defaulLabel))) {
         if (value.indexOf(defaulLabel) == 0) {
             value.splice(value.indexOf(defaulLabel), 1);
             this.val(value);
             console.log("Final ",value);
         } else {
             this.val(defaulLabel);
         }
         this.render();
     }
 })
 });
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@premranjithj

here you need to change defaulLabel variable value from All Shops to All values.

  var defaulLabel="All Shops";
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

How much can you really learn in 3 minutes?

Observability can certainly be hard to understand – there's a lot of jargon and buzzwords and it seems to ...

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...