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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...