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
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...