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!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...