Dashboards & Visualizations

How to change radio selction based on token?

matstap
Communicator

I have a dashboard where a panel with a radio selection is hidden until a selection has been made from a dropdown menu. The problem I'm having is when I select a radio button, hide the panel, then show the panel again the token value for the radio is unset (as desired) but the radio button is still selected.
I want the radio selection to go back to the default when hiding/unhiding the panel.

Here is the xml:

<form>
  <fieldset submitButton="false">
    <input type="dropdown" token="Product">
      <label>Product</label>
      <search>
        <query>some populating query</query>
      </search>
      <fieldForLabel>product</fieldForLabel>
      <fieldForValue>product</fieldForValue>
      <change>
        <condition value="">
          <unset token="Product"></unset>
        </condition>
        <condition match="(value!=&quot;&quot;)">
          <unset token="Reports"></unset>
        </condition>
      </change>
    </input>
  </fieldset>

  <row>
    <panel depends="$Product$">
      <input type="radio" token="Reports">
        <label>Reports</label>
        <choice value="">Select Report</choice>
        <fieldForLabel>search</fieldForLabel>
        <fieldForValue>search</fieldForValue>
        <search>
          <query>some populating query</query>
        </search>
        <change>
          <condition value="">
            <unset token="Reports"></unset>
          </condition>
        </change>
        <default></default>
      </input>
    </panel>
  </row>
</form>
0 Karma
1 Solution

tiagofbmm
Influencer

Ok I believe this does what you want. Choosing "LALA" in the dropdown resets hides the Radio and resets to default when you later choose one of the other dropdown values:

<form>
  <fieldset submitButton="false">
    <input type="dropdown" token="Product">
      <label>Product</label>
      <search>
        <query>index=_internal | head 1000 | dedup source | table source</query>
      </search>
      <fieldForLabel>source</fieldForLabel>
      <fieldForValue>source</fieldForValue>
      <change>
        <!--condition value="LALA">
          <unset token="Product"></unset>
        </condition-->
        <condition value="LALA">
          <set token="Reports"></set>
          <set token="form.Reports"></set>
          <unset token="Product"></unset>
        </condition>
      </change>
      <choice value="LALA">LALA</choice>
    </input>
  </fieldset>
  <row>
    <panel depends="$Product$">
      <input type="radio" token="Reports">
        <label>Reports</label>
        <choice value="">Select Report</choice>
        <fieldForLabel>source</fieldForLabel>
        <fieldForValue>source</fieldForValue>
        <search>
          <query>index=_internal | head 1000 | dedup source | table source</query>
        </search>
        <change>
          <condition value="Select Report"></condition>
        </change>
      </input>
    </panel>
  </row>
</form>

View solution in original post

tiagofbmm
Influencer

Ok I believe this does what you want. Choosing "LALA" in the dropdown resets hides the Radio and resets to default when you later choose one of the other dropdown values:

<form>
  <fieldset submitButton="false">
    <input type="dropdown" token="Product">
      <label>Product</label>
      <search>
        <query>index=_internal | head 1000 | dedup source | table source</query>
      </search>
      <fieldForLabel>source</fieldForLabel>
      <fieldForValue>source</fieldForValue>
      <change>
        <!--condition value="LALA">
          <unset token="Product"></unset>
        </condition-->
        <condition value="LALA">
          <set token="Reports"></set>
          <set token="form.Reports"></set>
          <unset token="Product"></unset>
        </condition>
      </change>
      <choice value="LALA">LALA</choice>
    </input>
  </fieldset>
  <row>
    <panel depends="$Product$">
      <input type="radio" token="Reports">
        <label>Reports</label>
        <choice value="">Select Report</choice>
        <fieldForLabel>source</fieldForLabel>
        <fieldForValue>source</fieldForValue>
        <search>
          <query>index=_internal | head 1000 | dedup source | table source</query>
        </search>
        <change>
          <condition value="Select Report"></condition>
        </change>
      </input>
    </panel>
  </row>
</form>

matstap
Communicator

This works. Thanks!

I made one change though. I added:

<condition value="*">
          <set token="Reports"></set>
          <set token="form.Reports"></set>
        </condition>

above <condition value="LALA"> to make the Reports reset when switching to other dropdown selections as well.

Thanks again!

0 Karma

tiagofbmm
Influencer

You're welcome 🙂

0 Karma

tiagofbmm
Influencer

Hi

Please use this generic test on your Splunk and adapt it. It is the same as yours but with some concrete values as examples. Let me know if it works for you

<form>
  <fieldset submitButton="false">
    <input type="dropdown" token="Product">
      <label>Product</label>
      <search>
        <query>index=_internal | head 1000 | dedup source | table source</query>
      </search>
      <fieldForLabel>source</fieldForLabel>
      <fieldForValue>source</fieldForValue>
      <change>
        <condition value="LALA">
          <unset token="Product"></unset>
        </condition>
        <condition match="(value=LALA)">
          <unset token="Reports"></unset>
        </condition>
      </change>
      <choice value="LALA">LALA</choice>
    </input>
  </fieldset>
  <row>
    <panel depends="$Product$">
      <input type="radio" token="Reports">
        <label>Reports</label>
        <choice value="">Select Report</choice>
        <fieldForLabel>source</fieldForLabel>
        <fieldForValue>source</fieldForValue>
        <search>
          <query>index=_internal | head 1000 | dedup source | table source</query>
        </search>
        <change>
          <condition value="">
            <unset token="Reports"></unset>
          </condition>
        </change>
        <default></default>
      </input>
    </panel>
  </row>
</form>
0 Karma

matstap
Communicator

I get the same behavior from this. The radio button isn't resetting to "Select Report" when I change the dropdown selection.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...