Dashboards & Visualizations

Fill default option from dropdown with a token

DanielSp
Explorer

Hello,

I have a dropdown that I need to be filled depending other dropdown
Dropdown1:
A->X
B->Y,Z
C->W,Z

If I selected A in the first one, I need that appear already selected X in the second dropdown
If I selected B in the second one, I need that appear already selected (change from previous selection) to Y,Z in the second dropdown
If I selected C in the thirstone, I need that appear already selected (change from previous selection) to W,Z in the second dropdown

I tried with a token in the first dropdown and put the follow code in the second dropdown
<default>$token$</default>
It would work with only ONE value, but I not achieve that work for B and C that have 2 values

Could you please help me with It?
Thanks a lot

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

If I understand correctly, the second dropdown is a multi-select which you want some of the options preselected based on the choice of the first dropdown?

    <input type="dropdown" token="choice" searchWhenChanged="true">
      <label>Choice</label>
      <choice value="X">A</choice>
      <choice value="Y,Z">B</choice>
      <choice value="W,Z">C</choice>
      <change>
        <eval token="form.preselect">split($choice$,",")</eval>
      </change>
    </input>
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Preselect</label>
      <choice value="W">W</choice>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <choice value="Z">Z</choice>
    </input>

View solution in original post

DanielSp
Explorer

Thanks a lot¡ It works¡

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If I understand correctly, the second dropdown is a multi-select which you want some of the options preselected based on the choice of the first dropdown?

    <input type="dropdown" token="choice" searchWhenChanged="true">
      <label>Choice</label>
      <choice value="X">A</choice>
      <choice value="Y,Z">B</choice>
      <choice value="W,Z">C</choice>
      <change>
        <eval token="form.preselect">split($choice$,",")</eval>
      </change>
    </input>
    <input type="multiselect" token="preselect" searchWhenChanged="true">
      <label>Preselect</label>
      <choice value="W">W</choice>
      <choice value="X">X</choice>
      <choice value="Y">Y</choice>
      <choice value="Z">Z</choice>
    </input>
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...