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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...