Splunk Search

How to execute javascript after a search?

big_nuggets
Explorer

Hi,

I've copied the Search & Reporting app folder as my own app in /etc/apps, now I want to add some JS to be executed after a search has finished. Everything I've tried hasn't worked, anyone ever figure out a way to do this?

I've tried changing isdashboard to True in search.xml, then specifying a JS file in script="myjs.js", it doesn't get executed, then I tried this:

<module name="AppBar" layoutPanel="appHeader">
    <param name="timsharkjs">timshark/timshark.js</param>
</module>

within search.xml, as I had seen another app (sideview_utils) doing something like this , didn't work.

Any help would be greatly appreciated, thank you.

Labels (1)
0 Karma

espirde
Engager

You can try to use an event listener when a specific search is done.

SearchID.on("search:done", function () {
// function here
}

gabriel_vasseur
Contributor

This doesn't work. It produces an error when the javascript is loaded.

I've tried:

    $("#NameSearchID").on( "search:done", function() {

Referring to this in the simple XML:

  <row>
    <panel>
      <table>
        <search id="NameSearchID">
...

Do you have a full working example?

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 ...