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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...