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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...