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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...