- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a requirement in dashboard. My multiselect input should remove ALL (default value) if I select any value other than that automatically and ALL should return if I deselect the selected value... Please help me to get this result?
<input type="multiselect" token="app_name">
<label>Application Name</label>
<choice value="*">All</choice>
<default>*</default>
<initialValue>*</initialValue>
<fieldForLabel>app_name</fieldForLabel>
<fieldForValue>app_name</fieldForValue>
<search base="base_search">
<query> |stats count by app_name </query>
</search>
<valuePrefix>app_name="</valuePrefix>
<valueSuffix>"</valueSuffix>
<delimiter> OR </delimiter>
</input>
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Try like this - note that your search needs to use the $app_name_choice$ token not $app_name$
<input type="multiselect" token="app_name">
<label>Application Name</label>
<choice value="All">All</choice>
<default>All</default>
<initialValue>*</initialValue>
<fieldForLabel>app_name</fieldForLabel>
<fieldForValue>app_name</fieldForValue>
<search base="base_search">
<query> |stats count by app_name </query>
</search>
<valuePrefix>app_name="</valuePrefix>
<valueSuffix>"</valueSuffix>
<delimiter> OR </delimiter>
<change>
<eval token="form.app_name">case(mvcount('form.app_name')=0,"All",mvcount('form.app_name')>1 AND mvfind('form.app_name',"All")>0,"All",mvcount('form.app_name')>1 AND mvfind('form.app_name',"All")=0,mvfilter('form.app_name'!="All"),1==1,'form.app_name')</eval>
<eval token="app_name_choice">if('form.app_name'=="All","app_name=\"*\"",'app_name')</eval>
</change>
</input>
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


I don't think you actually want to remove "ALL" from the multi-select...it makes it so people can go back to the default when they are done with whatever choice they made originally. I would say if you don't want people to go back to the default...then maybe you don't it there at all in the first place? Or maybe you don't actually want a multi-select but just a regular drop-down list? But it seems to me if you want it there in the first place, you actually want it there always so people can revert back to the default behavior of the dashboard when they are done messing around 😊 (IMO).
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You can do this without javascript - here is a SimpleXML example
<input type="multiselect" token="alloptions" searchWhenChanged="true">
<label>Options $alloptions$</label>
<choice value="All">All</choice>
<search>
<query>
| makeresults count=20
| streamstats count as row
| eval option="Option ".mvindex(split("ABCDEFGHIJKLMNOPQRSTUVWXYZ",""),row-1)
| eval label="Option ".mvindex(split("abcdefghijklmnopqrstuvwxyz",""),row-1)
| table option label
</query>
</search>
<fieldForLabel>label</fieldForLabel>
<fieldForValue>option</fieldForValue>
<delimiter>,</delimiter>
<change>
<eval token="form.alloptions">case(mvcount('form.alloptions')=0,"All",mvcount('form.alloptions')>1 AND mvfind('form.alloptions',"All")>0,"All",mvcount('form.alloptions')>1 AND mvfind('form.alloptions',"All")=0,mvfilter('form.alloptions'!="All"),1==1,'form.alloptions')</eval>
</change>
</input>
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is my existing multiselect XML..
<input type="multiselect" token="app_name">
<label>Application Name</label>
<choice value="*">All</choice>
<default>*</default>
<initialValue>*</initialValue>
<fieldForLabel>app_name</fieldForLabel>
<fieldForValue>app_name</fieldForValue>
<search base="base_search">
<query> |stats count by app_name </query>
</search>
<valuePrefix>app_name="</valuePrefix>
<valueSuffix>"</valueSuffix>
<delimiter> OR </delimiter>
</input>
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Try like this - note that your search needs to use the $app_name_choice$ token not $app_name$
<input type="multiselect" token="app_name">
<label>Application Name</label>
<choice value="All">All</choice>
<default>All</default>
<initialValue>*</initialValue>
<fieldForLabel>app_name</fieldForLabel>
<fieldForValue>app_name</fieldForValue>
<search base="base_search">
<query> |stats count by app_name </query>
</search>
<valuePrefix>app_name="</valuePrefix>
<valueSuffix>"</valueSuffix>
<delimiter> OR </delimiter>
<change>
<eval token="form.app_name">case(mvcount('form.app_name')=0,"All",mvcount('form.app_name')>1 AND mvfind('form.app_name',"All")>0,"All",mvcount('form.app_name')>1 AND mvfind('form.app_name',"All")=0,mvfilter('form.app_name'!="All"),1==1,'form.app_name')</eval>
<eval token="app_name_choice">if('form.app_name'=="All","app_name=\"*\"",'app_name')</eval>
</change>
</input>
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ITWhisperer thanks for the code. It is working but my doubt as per your comment - do I replace $app_name$ token with $app_name_choice$ in all my panels? Because even though I didn't change my panels are refreshing at the moment according to multiselect options given. Please confirm do I need to replace?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You probably do need to use app_name_choice in your panels if you want the All option to be converted to * otherwise your search will be for app_name="All" which is probably not what you want!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ITWhisperer thanks for the reply. Where I need to give this input? In my existing multiselect input?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In which component ( I mean deployer or direct search head) I need to give this JS? can you please specify full path?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Karthikeya
To achieve this you are probably best using some Javascript, have a look at these two links as I think they contain working examples for you to use:
Please let me know how you get on and consider upvoting/karma this answer if it has helped.
Regards
Will
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Essentially you need to create the following in a allSelect.js file in appname/appserver/static:
require([
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/simplexml/ready!'
], function($, mvc){
$('#multi').on("change",function(){
var multi1 = mvc.Components.get("multi");
var tokens = mvc.Components.getInstance("default");
var mytoken = tokens.get("multi")
if (mytoken.length > 1 && mytoken.includes("All"))
{
// If "All" was selected before current (more specific) selection, remove it from list
if (indexOfAll == 0)
{
var temp = mytoken.split(" ")
var temp1 = temp[1]
multi1.val(temp1);
} else
{
// "All" was selected last, clear input and leave only "All" in it
multi1.val("All");
}
}
});
});
Then update the first line of your dashboard to something like this:
<form script="allSelect.js">
