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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...