Dashboards & Visualizations

Dashboards - reset text fields value to "*" after submit

xZinou
Explorer

Hello,

I want to build a dashboard from which users can add rows to a lookup, in those rows many cells are calculated (for example an automatically generated ID for each row) and I want this to remain transparent for the user.

Users have to fill one or multiple text input fields, the fields left unchanged have to be set to * (I don't mind having * shows as an initial value in the input fields). Clicking the submit button must reset all fields again to *.

I tried adapting an existing answer about emptying the input fields but with no luck (I don't have enough Karma points to share the link).

I thank you in advance for your time and support.

Best regards.

0 Karma

vnravikumar
Champion

Hi

Check the following sample, here on click of submit button it will reset the text field to *

<form script="reset.js">
  <label>input</label>
  <fieldset submitButton="true">
    <input type="text" token="field1">
      <label>field1</label>
      <initialValue>*</initialValue>
      <default>*</default>
    </input>
    <input type="text" token="field2">
      <label>field2</label>
      <initialValue>*</initialValue>
      <default>*</default>
    </input>
  </fieldset>
</form>

javascript:

require([
    "jquery", 
    "splunkjs/mvc", 
    "splunkjs/mvc/simplexml/ready!"], function($, mvc) {
         var tokens = mvc.Components.get("default");
        $("#submit button").click(function(){
              tokens.unset("form.field1");
              tokens.unset("form.field2");
        });
    });
0 Karma

xZinou
Explorer

Hello,
Thank you for your answer.
This didn't work for me, I placed the reset.js file in the right place:
/opt/splunk/etc/apps/<appname>/appserver/static and restarted Splunk but had no luck.

0 Karma

vnravikumar
Champion

try with http://<<server-name>>:8000/en-US/_bump, any error are you getting in web browser console?

xZinou
Explorer

Hello,
Yes, indeed, I have a 404 error, hardcoding the script path doesn't help, Splunk insist on defining the base URL.
I couldn't specify the server name, SAML authentication revert me back to "splunk:8000".
Any ideas on how to resolve that (without disabling SAML for selected users) ?
Thank you.

0 Karma
Get Updates on the Splunk Community!

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 ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...