Knowledge Management

Why is an empty value from a MultiSelectInput deleting ALL the items in my KV Store?

thisissplunk
Builder

Not sure if this is a bug or what, but if I push the delete button on my dashboard and there are no values selected in the MultSelectInput, all of my kv store values are wiped out. One caveat is that you HAVE to legitimately delete a single value once before this bug shows up.

Typical use would be: select one value from the MultiSelectInput and then hit the Delete button.
Bugged process: delete one value, erase MultiSelectInput value so that the input is empty, hit Delete button. All values are now gone.

This deletes a single value in the kv store:

https://mysplunk.com/en-US/splunkd/__raw/servicesNS/nobody/search/storage/collections/data/mykvstore...

This deletes nothing (happens when I first load the page adn try to delete with a blank MultiSelectInput):

https://mysplunk.com/en-US/splunkd/__raw/servicesNS/nobody/search/storage/collections/data/mykvstore...

This deletes everything (happens after I delete one thing, then try to delete again with a blank MultiSelectInput):

https://mysplunk.com/en-US/splunkd/__raw/servicesNS/nobody/search/storage/collections/data/mykvstore...

I think this is a bug. Can anyone confirm?


Here is my input that selects KeyIDs to delete:

var input4 = new MultiSelectInput({
    "id": "input4",
    "choices": [],
    "valueField": "KeyID",
    "labelField": "KeyID",
    "value": "$form.KeyID$",
    "managerid": "search10",
    "el": $('#input4')
}, {tokens: true}).render();

input4.on("change", function(newValue) {
    FormUtils.handleValueChange(input4);
});

And here is my delete button and code:

   $("#deleteKeyID").click(function() {
        // Get the value of the key ID field
        var tokens = mvc.Components.get("default");
        var form_keyid = tokens.get("form.KeyID");

        // Delete the record that corresponds to the key ID using
        // the del method to send a DELETE request
        // to the storage/collections/data/{collection}/ endpoint
        service.del("storage/collections/data/mykvstore-test/" + encodeURIComponent(form_keyid))
            .done(function() { 
                // Run the search again to update the table
                search1.startSearch(); 

                // Clear the form fields THIS DOESN'T WORK FOR MULTISELECTINPUTS
                $("#formKeyDeletion input[type=text]").val("");
            });
        return false;
    }); 


    // Initialize time tokens to default
    if (!defaultTokenModel.has('earliest') && !defaultTokenModel.has('latest')) {
        defaultTokenModel.set({ earliest: '0', latest: '' });
    }

    if (!_.isEmpty(urlTokenModel.toJSON())){
        submitTokens();
    }
0 Karma
1 Solution

thisissplunk
Builder

Not sure if this is a bug or what, but it can be solved by unseting the MultiSelectInput token back to undefined after the delete button is pushed:

EventHandler.unsetToken("form.KeyID");

"Undefined" breaks the api and doesn't delete anything from the kv store, whereas "blank" will delete everything. Not sure why Splunk sets it back to blank after pushing the delete button once. See the three API posts above for examples.

View solution in original post

0 Karma

thisissplunk
Builder

Not sure if this is a bug or what, but it can be solved by unseting the MultiSelectInput token back to undefined after the delete button is pushed:

EventHandler.unsetToken("form.KeyID");

"Undefined" breaks the api and doesn't delete anything from the kv store, whereas "blank" will delete everything. Not sure why Splunk sets it back to blank after pushing the delete button once. See the three API posts above for examples.

0 Karma
Get Updates on the Splunk Community!

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

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

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...