All Apps and Add-ons

Simple XML - Setting time token back to default (reset)

lydiapal_splunk
Splunk Employee
Splunk Employee

Hi,
So I'm trying to set my time token back to default/reset using my "reset" button. Here's my code for my "reset" button. Although my <set token="time_tok.earliest">-30d</set> sets the time token correctly and my searches update, the label/name remains the same on the time token dropdown.

<input type="radio" token="reset_menus_tok" searchWhenChanged="true">
  <label>Reset form</label>
  <choice value="reset">Reset</choice>
  <change>
    <!--  other tokens here... -->
    <unset token="form.reset_menus_tok"></unset>
    <set token="time_tok.earliest">-30d@d</set>
    <set token="time_tok.latest">now</set>
  </change>
</input>

Here's my time token:

<input type="time" token="time_tok" searchWhenChanged="true">
  <label>Timerange</label>
  <default>
    <earliest>-30d@d</earliest>
    <latest>now</latest>
  </default>
</input>

So after clicking on reset, the time_tok.earliest and time_tok.latest are changed but the dropdown for time token still says the time selected previously, eg. "Last 7 Days".
Am I doing something wrong?

Many thanks!

0 Karma
1 Solution

vnravikumar
Champion

Hi @lydiapal [Splunk]

Try like form.time_tok.earliest and form.time_tok.latest

<form>
  <label>reset</label>
  <fieldset submitButton="false">
    <input type="radio" token="reset_menus_tok" searchWhenChanged="true">
      <label>Reset form</label>
      <choice value="reset">Reset</choice>
      <change>
        <!--  other tokens here... -->
     <set token="form.time_tok.earliest">-30d@d</set>
        <set token="form.time_tok.latest">now</set>
      </change>
    </input>
    <input type="time" token="time_tok" searchWhenChanged="true">
      <label>Timerange</label>
      <default>
        <earliest>-30d@d</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
</form>

View solution in original post

0 Karma

vnravikumar
Champion

Hi @lydiapal [Splunk]

Try like form.time_tok.earliest and form.time_tok.latest

<form>
  <label>reset</label>
  <fieldset submitButton="false">
    <input type="radio" token="reset_menus_tok" searchWhenChanged="true">
      <label>Reset form</label>
      <choice value="reset">Reset</choice>
      <change>
        <!--  other tokens here... -->
     <set token="form.time_tok.earliest">-30d@d</set>
        <set token="form.time_tok.latest">now</set>
      </change>
    </input>
    <input type="time" token="time_tok" searchWhenChanged="true">
      <label>Timerange</label>
      <default>
        <earliest>-30d@d</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
</form>
0 Karma

lydiapal_splunk
Splunk Employee
Splunk Employee

Ahh.. thanks heaps!!

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...