Dashboards & Visualizations

How to go about dropdown default value based on another dropdown?

Gabri
Explorer

I have the following dropdowns, now if I select test1 and then test11 in the second dropdown, when I change the first one to be test2, the second dropdown holds the old value and shows test11 although that's not a valid option.

 

 

<form version="1.1" theme="dark">
  <fieldset>
    <input type="dropdown" token="test">
      <label>Test</label>
      <choice value="*">All</choice>
      <choice value="test1">test1</choice>
      <choice value="test2">test2</choice>
    </input>
    <input type="dropdown" token="dependsontest" searchWhenChanged="false">
      <label>DependsOnTest</label>
      <fieldForLabel>$test$</fieldForLabel>
      <fieldForValue>$test$</fieldForValue>
      <choice value="*">All</choice>
      <search>
        <query>| makeresults
| fields - _time
| eval test1="test11,test12",test2="test21,test22" 
| fields $test$
| makemv $test$ delim=","
| mvexpand $test$</query>
      </search>
    </input>
    </fieldset>
</form>

 

 


I tried the <selectFirstChoice>true</selectFirstChoice> and default values but those didn't work. How can I go about this ?

EDIT: I tried using the "change" and "condition" and found out that the "dependsontest" token gets updated but the dropdown UI doesn't.

Labels (1)
0 Karma
1 Solution

Gabri
Explorer

Here is what I was trying before, where the "dependsontest" token would get updated but the UI would show a stale value.

      <change>
          <set token="dependsontest">All</set>
      </change>

 

Here is what I am doing now and it updates both the token AND the UI

 

      <change>
          <set token="form.dependsontest">All</set>
      </change>

View solution in original post

Gabri
Explorer

Here is what I was trying before, where the "dependsontest" token would get updated but the UI would show a stale value.

      <change>
          <set token="dependsontest">All</set>
      </change>

 

Here is what I am doing now and it updates both the token AND the UI

 

      <change>
          <set token="form.dependsontest">All</set>
      </change>

Gabri
Explorer

I think I found the underlying issue but not a solution for it. I used a "change" like richgalloway suggested and the actual token gets updated but the dropdown UI still shows a stale value.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

As an untested idea, try adding code to unset the second token when the first one changes.

<form version="1.1" theme="dark">
  <fieldset>
    <input type="dropdown" token="test">
      <label>Test</label>
      <choice value="*">All</choice>
      <choice value="test1">test1</choice>
      <choice value="test2">test2</choice>
      <change>
         <unset token="dependsontest"/>
      </change>
    </input>
    <input type="dropdown" token="dependsontest" searchWhenChanged="false">
      <label>DependsOnTest</label>
---
If this reply helps you, Karma would be appreciated.
0 Karma

astockmeister_s
Explorer

Can this be done in Dashboard Studio JSON configuration?

0 Karma

Gabri
Explorer

This was interesting, I tried some variations of your approach but the old choice still stays

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...