Dashboards & Visualizations

How to clear the old values of a multiselect input when I change the value on another drop-down in my Simple XML dashboard?

sjain135
Engager

I would like to clear the old values of a multiselect input when I change the value on another drop-down. Actually, when I change the value in first drop-down, then the multiselect value does not clear the already selected value. It is taking the new values, but due to old selected value, the result in not coming as expected.

Does someone have any solution for this? I am using Simple XML in dashboard.

adevi
Explorer

I found out this answer helpful:

link here
[https://answers.splunk.com/answers/218751/selectfirstchoice-not-working-in-dynamic-dropdowns.html]

The above link did not explain it clearly.

In your drop-down Simple XML, unset the multiselect token. Make sure you specify "form. your-token-name" in the unset tag:

   <change>
        <unset token="form.my_id_name_multiselect"></unset>
      </change>

Full code

<form>
<fieldset submitButton="true" autoRun="false">
    <input type="dropdown" token="my_id" searchWhenChanged="false">
          <label>Network</label>
          <search>
            <query> index="someindex" | top ids </query>
            <earliest>@d</earliest>
            <latest>now</latest>
          </search>
          <choice value="*">All</choice>
          <change>
            <unset token="form.my_id_name_multiselect"></unset>
          </change>
          <default>*</default>
          <initialValue>*</initialValue>
        </input>
 <input type="multiselect" token="my_id_name_multiselect" searchWhenChanged="false">
      <label>Name</label>
      <choice value="*">All</choice>
      <search>
        <query>ndex="someindex" | where id=$my_id$ | table id_name</query>
        <earliest>@d</earliest>
        <latest>now</latest>
      </search>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>(</prefix>
      <suffix>)</suffix>
      <valuePrefix>id_name="</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter> OR </delimiter>
    </input>
</fieldset>
</form>

Hope this helps

richielynch89
Path Finder

Thank you adevi! Works perfect for me.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...