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

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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