Splunk Search

Match condition to unset a token based on value in input field

praphulla1
Path Finder

I am trying to clear a input field based on user's input. I am able to clear input field by using unset form.token

I have added condition on unset by comparing with another toke. For some reason the condition does not work.

Below is my sample test code. I am not able to understand if there's a issue with my match condition.

<form>
  <label>My Test Dashboard Pra</label>
  <description>This is developer test dashboard</description>
  <fieldset submitButton="false">
    <input type="multiselect" token="field1">
      <label>field1</label>
      <choice value="1">One</choice>
      <choice value="2">Two</choice>
      <choice value="3">Three</choice>
      <choice value="*">ALL</choice>
      <default>*</default>
      <change>
        <condition match="$field3$==0">
          <unset token="form.field2"></unset>
        </condition>
      </change>
    </input>
    <input type="multiselect" token="field2">
      <label>field2</label>
      <choice value="10">Ten</choice>
      <choice value="20">Twenty</choice>
      <choice value="*">ALL</choice>
      <default>*</default>
    </input>
    <input type="checkbox" token="field3">
      <label>field3</label>
      <choice value="0">Clear input on change</choice>
      <default>0</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>field1 = $field1$   field2 = $field2$ field3 == $field3$</title>
      <table>
        <title>Test Panel</title>
        <search>
          <query/>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
0 Karma
1 Solution

spavin
Path Finder

If you tweak the match condition on line 13 slightly it will give you what you're looking for:

        <condition match=" $field3$ == &quot;0&quot;">

This is testing to see if $field3$ is equal to the string "0", rather than to the integer 0.

Check out the examples from docs:
https://docs.splunk.com/Documentation/Splunk/7.2.4/Viz/tokens#Define_tokens_for_conditional_operatio...

View solution in original post

0 Karma

spavin
Path Finder

If you tweak the match condition on line 13 slightly it will give you what you're looking for:

        <condition match=" $field3$ == &quot;0&quot;">

This is testing to see if $field3$ is equal to the string "0", rather than to the integer 0.

Check out the examples from docs:
https://docs.splunk.com/Documentation/Splunk/7.2.4/Viz/tokens#Define_tokens_for_conditional_operatio...

0 Karma

praphulla1
Path Finder

@spavin Thank you.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...