Splunk Search

Adding evaluated token breaks searchWhenChanged="false"?

matstap
Communicator

I have a dashboard where the input fields are set to searchWhenChanged="false". This was working as expected until I added an evaluated token from the value of one of these fields. Now, when I change the value of the input field associated with the evaluated token, the results table search automatically runs. Any suggestions on how to stop this?

Here is the token evaluation:

var offset = new DropdownInput({
            "id": "offset",
            "choices": [
                {"label": "GMT", "value": "0"},
                {"label": "PDT", "value": "25200"}
            ],
            "searchWhenChanged": false,
            "initialValue": "0",
            "selectFirstChoice": false,
            "showClearButton": true,
            "default": "0",
            "value": "$form.offset$",
            "el": $('#offset')
        }, {tokens: true}).render();

        offset.on('change', function(newValue) {
            FormUtils.handleValueChange(offset);
        });

        offset.on("valueChange", function(e) {
            if (e.value !== undefined) {
                EventHandler.evalToken("timezone", "$label$", e.data);
            }
        });
0 Karma
1 Solution

matstap
Communicator

I found another way to achieve this. Instead of using an EventHandler.evalToken(...) , I just grab the dropdown elements text.() and use it to set the "timezone" token when the submit button is pressed.

submit.on("submit", function() {
            var timezone = $('#offset').text().match(/\w+/)[0]; 
            setToken('timezone', timezone);
            ...

            submitTokens();
        });

View solution in original post

matstap
Communicator

I found another way to achieve this. Instead of using an EventHandler.evalToken(...) , I just grab the dropdown elements text.() and use it to set the "timezone" token when the submit button is pressed.

submit.on("submit", function() {
            var timezone = $('#offset').text().match(/\w+/)[0]; 
            setToken('timezone', timezone);
            ...

            submitTokens();
        });

nick405060
Motivator
0 Karma

horsefez
Motivator

Hey @matstap,
great that you found the solution by yourself. Also many thanks to you for telling others how to handle this situation, if they ever encounter it. (Posting their working solutions is what most users forget here.)

0 Karma

renjith_nair
Legend

Do you have a submit button to run the search after all tokens are set?

You could try removing the onchange event, in this case

         offset.on('change', function(newValue) {
             FormUtils.handleValueChange(offset);
         });
Happy Splunking!
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 ...