Dashboards & Visualizations

startSearch in Splunk 6.6.2

oleg_kirichenko
New Member

Hello!

Here is my xml:

<form script="next-prev-btn.js">
  <label>Test Next-Prev btn onclick</label>
  ...
  ...
  <row>
    <panel>
      <title>Title1</title>
     ...
     ...
      <html>
         <div>
           <button id="pr_button" class="btn btn-primary" onclick="prevpage()">Назад</button>
           <button id="nxt_button" class="btn btn-primary" style="float: right;">Далее</button>
         </div>
       </html>
    </panel>
  </row>
</form>

and this is my js:

require([
    "jquery",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/simplexml/ready!"
  ], function(
      $,
      SearchManager
  ) {
      var mysearch = new SearchManager({
          id: "mysearch",
          autostart: "false",
          search: "| gentimes start=-1| eval time=\"06.06.2017 10:00\" | eval field4=\"$field4$\" | eval field5=\"$field5$\" | outputlookup $field1$$field2$$field3$.csv"  
      }, {tokens: true, tokenNamespace: "submitted"});
      $("#nxt_button").on("click", function (){
        mysearch.startSearch();
        window.open ('localhost:8000/en-US/app/testform/test-form-next-button2','_self',false);
      });
 });

It works good when I use Splunk 6.3.3 but it does not work on Splunk 6.6.2
I'm get an error:

Uncaught TypeError: startSearch() is not a function
0 Karma

danillopavan
Communicator

I am facing the same issue using the function startSearch() for the version 6.6.2. Do someone know why this issue happens?,I am facing the same issue with the function "startSearch()" for the version 6.6.2. Do someone know why it happens?

0 Karma

niketn
Legend

@oleg_kirichenko, are you seeing the above error in JavaScript Console log?

I tried the following JavaScript Code. While it did not error out. window.open just seem to refresh the page. I am not sure how search results can be shown in the new window (based on your example seems like you are opening a separate dashboard in the same window)

require([
    "jquery",
    "splunkjs/mvc/utils",
    "splunkjs/ready!",
    "splunkjs/mvc/simplexml/ready!",
    "splunkjs/mvc/searchmanager",
], function(
            $,
            utils,
            SearchManager){
        var SearchManager = require("splunkjs/mvc/searchmanager");      
        var search1 = new SearchManager({
                    "id": "search1",
                    "search": "| makeresults | eval value=\"Search Result\"",
                    "earliest_time": "$earliest$",
                    "cancelOnUnload": true,
                    "status_buckets": 0,
                    "sample_ratio": null,
                    "latest_time": "$latest$",
                    "app": utils.getCurrentApp(),
                    "auto_cancel": 90,
                    "preview": true,
                    "tokenDependencies": {
                    },
                    "runWhenTimeIsUndefined": false
                }, {tokens: true, tokenNamespace: "submitted"});            
         $("#nxt_button").on("click", function (){
           search1.startSearch();
           window.open ("http://localhost:8000/en-US/app/<MyApp>/<MyDashboard>","_self",false);
         });
});

What do you want to achieve through startSearch()? Can a token be directly passed from main dashboard to the next one while keeping the browser window same?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...