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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...