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!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...