Dashboards & Visualizations

How to clear the previous value of the token in the form

ohuchi
Explorer

Please let me know the way to clear the previous value of the token.

I created the dashboard which has two input fields.

The first input field is for "Model".

The second input field is for "Host".

Each Host has only one Model.

One Model has some Host(s).

For example, at the begining, the value of the tokens are the default value.(T-Host = "*")

  1. select M-1 for Model (I can select H-1-1 or H-1-2 for Host)
  2. select H-1-2 (T-Model="M-1", T-Host = "H-1-2")
  3. select M-2 for Model (I can select H-2-1 or H-2-2 for Host)

At this timing the second input field shows nothing.

But the value of T-Host is still "H-1-2".

I expect the value of T-Host is "*"(default).

I can not find the way to clear the value(set the default value) of token automatically when the relative field was changed.

The bottom part (panel chart) of the source code is for confirming the value of tokens.

regards,

ABSTRACTION OF THE SOURCE CODE ###

<form>

  <fieldset autoRun="true" submitButton="false">

    <input type="dropdown" searchWhenChanged="true" token="T-Model">

      <populatingSearch fieldForValue="Nam-M">SEARCH-STRING-1 | table Nam-H Nam-M]</populatingSearch>

      <label>Model</label>

    </input>

    <input type="dropdown" searchWhenChanged="true" token="T-Host">

      <populatingSearch fieldForValue="Nam-H">SEARCH-STRING-2(Nam-M=$T-Model$) | table Nam-H Nam-M]</populatingSearch>

      <label>Host</label>

      <default>*</default>

    </input>

  </fieldset>

  <row><panel><chart>

    <title>T-Model=[$T-Model$] T-Host=[$T-Host$]</title>

    <searchString>SEARCH-STRING-3</searchString>

  </chart></panel></row>

</form>

Tags (2)

rupandit18
Engager

Dear Ohuchi,

Did you find the solution to this problem ? I am facing the same issue. If so, could you please share the solution ?

Thanks

0 Karma

dfoster_splunk
Splunk Employee
Splunk Employee

Sounds like you want the Host field to be set to "*" whenever the Model field changes.

You could listen to changes in the Model field and force the Host field to "*" whenever that happens. However that would also make links/drilldowns to the dashboard be unable to set Host to anything other than asterisk, as all other values would get clobbered during page load.

Should you want to take this approach anyway, you could create a JS file in appserver/static and include it with <form script="myscript.js">:

require(['splunkjs/ready!'], function(mvc) {
    var tokens = mvc.Components.get('default');
    tokens.on('change:T-Model', function() {
        tokens.set('T-Host', '*');
    });
});

ohuchi
Explorer

Dear dfoster_splunk,
Thank you for your reply.
I created the myscriot.js file, and modified the form.
But it does not work well.
so, I am investigating now.
When I can set the default value to T_Host when T_Model changed, I will let you know.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...