Getting Data In

How to have dynamic form inputs/prompts reset their values to default upon selecting a new input of the Parent prompt?

tdiestel
Path Finder

HI All;

I have and issue dealing with a dynamic prompt:

  • I have 3 prompts. The first prompt selects the day and the next 2 prompts give a start and end timestamp for that day. The prompts works well at first, but when i switch the first prompt from the default date to another date, the time stamps associated with the first date stay as the values for the other 2 prompts, which produce zero results because those time stamps are for another day. Is there a way that I can make those 2 prompts just reset to the default value, which is the selectFirstChoice?

Here's my code below:

<form refresh="9999999360"> 
<label>Venue F&amp;B Dashboard</label> 
<fieldset submitButton="false"> 
<input type="dropdown" token="date" searchWhenChanged="true"> 
<label>Select a Date:</label> 
<search> 
<query>|inputlookup lookup_mobile_events_metadata.csv |stats count| eval time="Today"|eval row=0|append[| `macro_Ndays_timepickernew(10)`| streamstats count as row|eval row=row*(-1)]|eval next_day=row+1</query> 
<earliest>-24h</earliest> 
<latest>now</latest> 
</search> 
<fieldForLabel>time</fieldForLabel> 
<fieldForValue>row</fieldForValue> 
<default>0</default> 
<change> 
<set token="date_after">$row.next_day$</set> 
</change> 
</input> 
<input type="dropdown" token="earliest_timestamp" searchWhenChanged="true"> 
<label>From:</label> 
<search> 
<query>| `Macro_To_and_From_Timepicker_To($date$,$date_after$,starttime)`</query> 
<earliest>0</earliest> 
</search> 
<fieldForLabel>starthuman</fieldForLabel> 
<fieldForValue>starttime</fieldForValue> 
<selectFirstChoice>true</selectFirstChoice> 

</input> 
<input type="dropdown" token="latest_timestamp" searchWhenChanged="true"> 
<label>To:</label> 
<search> 
<query>| `Macro_To_and_From_Timepicker_To($date$,$date_after$,endtime)`</query> 
<earliest>0</earliest> 
</search> 
<fieldForLabel>endhuman</fieldForLabel> 
<fieldForValue>endtime</fieldForValue> 
<selectFirstChoice>true</selectFirstChoice> 

where macro definitions are below:

[macro_Ndays_timepicker(1)] 
args = days 
definition = gentimes start=-$days$ end=0|eval time=strftime(starttime,"%Y %B %d")|sort - starttime|rename starttime as dateadded_epoch 
iseval = 0 

[Macro_To_and_From_Timepicker_To(3)] 
args = start,end,startorendtime 
definition = gentimes start=$start$ end=$end$ increment=30m| sort + starttime|eval display_time=strftime($startorendtime$,"%H:%M") 
iseval = 0 

here's pics of the issue:
The prompts appear all fine for today June 19th,
alt text

But when I change from the 19th to the 16th in the first prompt, the next 2 prompts don't update the chosen value and instead keep the selected Epoch timestamp they had for the 19th. Although as you can see, in the back end the choices did change, so the user would then just have to select an appropriate time for the selected date.

alt text

Any suggestions?

Thanks,
Tyler

1 Solution

tdiestel
Path Finder

Hi All;

Just an update on this:

To accomplish this goal, my team worked with splunk support and solved this by following these steps, which basically involve a logic to unset the token for the next two prompts right after the first prompt's token is set. Below is the fix for just the "From" time-prompt :

1.) open the original deep.xml code
2.) in the xml, change:

<input type="dropdown" token="fromtime" searchWhenChanged="false">

to

<input type="dropdown" token="fromtime" searchWhenChanged="true">

3.) Save and convert the dashboard to HTML dashboard which would give you a following source: see attached deep.html

4.) In the HTML source, go to the following piece of code (lines: 296 - 300):

input1.on("valueChange", function(e) {
    if (e.value !== undefined) {
        EventHandler.unsetToken("form.fromtime");
    }
});

And change it to look something like this:

input1.on("valueChange", function(e) {
    if (e.value !== undefined) {
        if(urlTokenModel.get("form.fromtime") && !submittedTokenModel.get("form.fromtime")) {
            return;
        }
        EventHandler.unsetToken("form.fromtime");
    }
});

5.) Now save and open the dashboard.

View solution in original post

tdiestel
Path Finder

Hi All;

Just an update on this:

To accomplish this goal, my team worked with splunk support and solved this by following these steps, which basically involve a logic to unset the token for the next two prompts right after the first prompt's token is set. Below is the fix for just the "From" time-prompt :

1.) open the original deep.xml code
2.) in the xml, change:

<input type="dropdown" token="fromtime" searchWhenChanged="false">

to

<input type="dropdown" token="fromtime" searchWhenChanged="true">

3.) Save and convert the dashboard to HTML dashboard which would give you a following source: see attached deep.html

4.) In the HTML source, go to the following piece of code (lines: 296 - 300):

input1.on("valueChange", function(e) {
    if (e.value !== undefined) {
        EventHandler.unsetToken("form.fromtime");
    }
});

And change it to look something like this:

input1.on("valueChange", function(e) {
    if (e.value !== undefined) {
        if(urlTokenModel.get("form.fromtime") && !submittedTokenModel.get("form.fromtime")) {
            return;
        }
        EventHandler.unsetToken("form.fromtime");
    }
});

5.) Now save and open the dashboard.

asimagu
Builder

I believe this does no longer apply to the newest version of Splunk.
What happened when you upgraded?

0 Karma

vvemula
Path Finder

Is it resolved now? we are using 6.3.2 and still facing the same problem

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...