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>

View solution in original post

0 Karma

lydiapal_splunk
Splunk Employee
Splunk Employee

Ahh.. thanks heaps!!

0 Karma
Did you miss .conf21 Virtual?

Good news! The event's keynotes and many of its breakout sessions are now available online, and still totally FREE!