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!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...