Dashboards & Visualizations

Unset token depending on input in other token

Julieda
Explorer

I have a dashboard with two text input fields. One of them (lets call it input1) has default value "*" which automatically generates a list of data. The other input (input2) generates another panel - and rejects the default list generated from input1. Only one of these panels shows at a time, depending on which input field is in use. The problem here is that input1 still has its default value when input2 has received input text.

I want to unset the token from input1 when input2 is in use - in other words I want to remove "*" and set the token to empty.
Does anybody know how I can solve this problem?

0 Karma

bsellapi
New Member

Use below code
newvalue is dropdown value

if (newValue !== undefined) {
if(urlTokenModel.get("form.tokenstring") && !submittedTokenModel.get("form.tokenstring")) {
return;
}
EventHandler.unsetToken("form.tokenstring"); ---> to unset token
}

0 Karma

chimell
Motivator

Hi
I think that this example will help you. Let copy it and test in your splunk web

<form>
   <label>Show Hide Using checkbox</label>
   <fieldset submitButton="false">
     <input type="text" token="sourcetypetable" searchWhenChanged="true">
       <label>Select Charts</label>
       <choice value="sourcetype">Show Sourcetype Count</choice>
     </input>
     <input type="text" token="hosttable" searchWhenChanged="true">
       <label>Select Charts</label>
       <choice value="host">Show Host Count</choice>
     </input>
   </fieldset>
   <row>
     <panel>
       <table depends="$sourcetypetable$">
         <search>
           <query>index=_internal | stats c by sourcetype</query>
           <earliest>-60m@m</earliest>
           <latest>now</latest>
         </search>
       </table>
     </panel>
     <panel>
       <table depends="$hosttable$">
         <search>
           <query>index=_internal | stats c by host</query>
           <earliest>-60m@m</earliest>
           <latest>now</latest>
         </search>
       </table>
     </panel>
   </row>
 </form>
0 Karma

Julieda
Explorer

That does not solve my problem, as I initially want input1 to have default value "ALL" (so that the first table initially is fully shown when loading the dashboard), and when writing input to input2 I want to clear the ALL from inputfield1.
But I appreciate the answer though. 🙂

0 Karma
Get Updates on the Splunk Community!

Optimize Cloud Monitoring

  TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...