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>
@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>
@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
@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?
@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
@premranjithj
Can you please share your full JS?
@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();
}
})
});
@premranjithj
here you need to change defaulLabel
variable value from All Shops
to All values
.
var defaulLabel="All Shops";