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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...