Splunk Search

How to clear SearchManager results once processed with on('data')

bowesmana
SplunkTrust
SplunkTrust

I have a modal dialog that pops up and shows a table of results. When I click OK on that, I do some processing on the results. as below, with the on('data') function.

However, that code seems to get triggered frequently and I don't understand why.

    var searchResults = detailSearch.data('results');
 ...
     searchResults.on('data', function() {
       var rows = searchResults.data().rows;
       for (var i = 0; i < rows.length; i++) {
 ...
       }
     });

That code is inside the button click handler, but the button click code is not executed repeatedly, only the above on('data') function code. The search is not rerun and in my close() code for the dialog, it calls search.finalize() to try to stop this happening, to no effect.

Any idea how I can reset the searchResults handler to prevent this?

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...