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);
         });
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...