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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...