Can we limit the number of choices in the multiselect input?
I want to have an input as multiselect built from a search and limit the number of select e.g. to 2.
Not sure if there is an actual option for that in simple xml, but maybe something like this?
Doesn't seem to work without enabling search on change, but could be something i'm missing there. It's the change tag that decides whether new items are allowed. Essentially after the user adds a 3rd, we change it back to only the first 2. Could also keep the last and remove the first if you wanted.
<input type="multiselect" token="t_comp" searchWhenChanged="true">
<label>Component</label>
<search>
<query>index=_internal | stats count by component</query>
<earliest>-60m@m</earliest>
<latest>now</latest>
</search>
<change>
<eval token="form.t_comp">if(mvcount('form.t_comp')=3, mvindex('form.t_comp',0,1),'form.t_comp')</eval>
</change>
<fieldForLabel>component</fieldForLabel>
<fieldForValue>component</fieldForValue>
<delimiter> OR </delimiter>
<prefix>(</prefix>
<suffix>)</suffix>
<valuePrefix>component = "</valuePrefix>
<valueSuffix>"</valueSuffix>
</input>
And of course if you only want to limit to 2, you could also just build 2 dropdowns.
awesome. thanks. I adjusted the eval with a different token name to make it work.
great, glad to help...don't forget to accept the answer too