Splunk Search

How do you reset a dashboard field after hitting the submit button?

mrtolu6
Path Finder

I have a dashboard form that uses free text inputs to write into a CSV file. How do I get the fields to reset after I hit the submit button?

Is it possible to create a dashboard using datepicker to select a date that would write into the lookup?

Tags (1)
0 Karma

mstjohn_splunk
Splunk Employee
Splunk Employee

hi @mrtolu6,

Did you have a chance to check out @niketnilay 's answer? If it worked, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya.

Thanks for posting!

0 Karma

niketn
Legend

@mrtolu6 please try the following run anywhere example. It takes a text input and displays the same in the panel. Once the Panel Search completes the text box token is cleaned up.

The <change> event handler of the text box is used to set the token passed in the search for the panel (using text box's predefined token $value$ to access selected text box value on change). In case the Text box value is null or empty token is not set.

      <change>
        <condition match="isnotnull($value$) AND $value$!=&quot;&quot;">
          <set token="tokTextFilter">$value$</set>
        </condition>
      </change>

On completing the search, the <done> event handler is used to <unset> the Text Box value:

          <done>
            <unset token="form.tokData"></unset>
          </done>

Please check out the following complete Simple XML code and try out to confirm whether it fits your needs.

<form>
  <label>Text Box Token Reset</label>
  <fieldset submitButton="false">
    <input type="text" token="tokData">
      <label>field1</label>
      <change>
        <condition match="isnotnull($value$) AND $value$!=&quot;&quot;">
          <set token="tokTextFilter">$value$</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row depends="$tokTextFilter$">
    <panel>
      <table>
        <search>
          <query>| makeresults 
| fields - _time
| eval data= "$tokTextFilter$"</query>
          <earliest>-1s</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
          <done>
            <unset token="form.tokData"></unset>
          </done>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

DanEhrlich
Loves-to-Learn

This works to clear the form field.  But the URL is not modified to reflect this fact.  So, if the page gets refreshed by the user or was left open when the browser was shut down and the user has the start where I left off option set the page will rerun the dash board.

How does one clear the field and reset the URL to reflect that fact?

0 Karma

xZinou
Explorer

Hello,
Can you please help reset inputs into a "default" value? I want to set my inputs to "*" after submitting.
Thank you very much.
BR.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...