All Apps and Add-ons

How to pass search results to custom JavaScript module

kasu_praveen
Communicator

In my view I am creating a table with search results

 


| eval abc = .....
| eval def = .....
| eval ghi = .....
| table abc, def, ghi



Now I want to define custom module in same view and pass search results (Ex: abc, def, ghi) to custom module JavaScript code. How can I do that? I am not using JS SDK.

Ex: sample custom module in view

 

doSomethingWithResults

Ex: sample custom code in application.js

 
Sideview.utils.declareCustomBehavior("doSomethingWithResults", function(customBehaviorModule) {
???????
???????
???????
// Here I want to read search results "abc","def","ghi"....
});

Thanks for looking into it.

0 Karma
1 Solution

kasu_praveen
Communicator

My XML Code:

<module name="Search" layoutPanel="appHeader">
    <param name="search"> <Write your search query here> | table abc def ghi</param>
    <module name="ResultsValueSetter">
        <param name="fields">abc,def,ghi</param>
        <module name="CustomBehavior">
            <param name="customBehavior">MyCustomMethod</param> 
        </module>
    </module>
</module>

MY JavaScript Code

Sideview.utils.declareCustomBehavior("MyCustomMethod", function(MyCustomMethodList) {
        MyCustomMethodList.onContextChange = function() {
            var context = this.getContext();
            var abcValue = context.get("abc");
            var defValue = context.get("def");
            var ghiValue = context.get("ghi");
            // Write your code by utilizing above "abcValue", "defValue" and "ghiValue" values.
        }
    });

This is working as expected. Thank you @sideview (Nick) for your suggestion.

View solution in original post

kasu_praveen
Communicator

@redc I have provided my answer below.

0 Karma

kasu_praveen
Communicator

My XML Code:

<module name="Search" layoutPanel="appHeader">
    <param name="search"> <Write your search query here> | table abc def ghi</param>
    <module name="ResultsValueSetter">
        <param name="fields">abc,def,ghi</param>
        <module name="CustomBehavior">
            <param name="customBehavior">MyCustomMethod</param> 
        </module>
    </module>
</module>

MY JavaScript Code

Sideview.utils.declareCustomBehavior("MyCustomMethod", function(MyCustomMethodList) {
        MyCustomMethodList.onContextChange = function() {
            var context = this.getContext();
            var abcValue = context.get("abc");
            var defValue = context.get("def");
            var ghiValue = context.get("ghi");
            // Write your code by utilizing above "abcValue", "defValue" and "ghiValue" values.
        }
    });

This is working as expected. Thank you @sideview (Nick) for your suggestion.

redc
Builder

@kasu_praveen - did you ever get this figured out? I'd like to do the same thing.

0 Karma

sideview
SplunkTrust
SplunkTrust

If you want to do something custom where you're operating on the search result rows, then I do not think you want a splunk UI module, but rather a custom search command.

http://docs.splunk.com/Documentation/Splunk/5.0.2/AdvancedDev/SearchScripts

What exactly do you want to do with the results though? If you just want to do things with field values that are on the first row only, then look into the documentation for the ResultsValueSetter module. If you just want to display field values from the search results of the first few result rows then look into the documentation for the HTML module. Beyond these simple use cases , operating on large numbers of result rows is really not what the User Interface layer is good at and you'll want to look at writing a custom search command.

Get Updates on the Splunk Community!

Application management with Targeted Application Install for Victoria Experience

  Experience a new era of flexibility in managing your Splunk Cloud Platform apps! With Targeted Application ...

Index This | What goes up and never comes down?

January 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Splunkers, Pack Your Bags: Why Cisco Live EMEA is Your Next Big Destination

The Power of Two: Splunk &#43; Cisco at "Ludicrous Scale"   You know Splunk. You know Cisco. But have you seen ...