<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I reference a search job in JavaScript? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361726#M23586</link>
    <description>&lt;P&gt;If the accepted answer doesn't work for you then you should post a new question describing your particular situation.&lt;/P&gt;</description>
    <pubDate>Sun, 31 May 2020 14:21:52 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-05-31T14:21:52Z</dc:date>
    <item>
      <title>How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361720#M23580</link>
      <description>&lt;P&gt;Im doing some custom javascript magic in a dashboard were I have a need for re-running a search&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search id="rerun_me_after_button_is_clicked"&amp;gt;
&amp;lt;query&amp;gt; ... &amp;lt;/query&amp;gt;
&amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I rerun this in my javascript through referring to the id? (or some other identifier)?&lt;/P&gt;
&lt;P&gt;my idea is something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;var sm = new SearchManager({
  id: "rerun_me_after_button_is_clicked",
  earliest_time: "-24h@h",
  latest_time: "now",
  preview: true,
  cache: false
  }

sm.StartSearch()
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure if this is how it works though?&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 23:45:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361720#M23580</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2020-06-07T23:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361721#M23581</link>
      <description>&lt;P&gt;Hi @christoffertoft,&lt;/P&gt;

&lt;P&gt;Can you please try by adding below line to execute search ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.get("rerun_me_after_button_is_clicked").startSearch();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your javascript would be like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    require([
        'underscore',
        'jquery',
        'splunkjs/mvc',     
        'splunkjs/mvc/simplexml/ready!'], function (_, $, mvc) {
        ( 'splunkjs/mvc/simplexml/ready!',  )

        .
        .
        .
        .
mvc.Components.get("rerun_me_after_button_is_clicked").startSearch();
    .
        .
        .
        .

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 15:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361721#M23581</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-02-08T15:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361722#M23582</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
      'underscore',
      'jquery',
      'splunkjs/mvc',
      'splunkjs/mvc/tableview',
      'splunkjs/mvc/simplexml/ready!'
  ], function(_, $, mvc, TableView) {

  $(document).ready(function () {
         $("#mybutton").on("click", function (e) {
            var mySearch = mvc.Components.get("rerun_me_after_button_is_clicked");
            mySearch.startSearch();
         });
     });

  });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 15:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361722#M23582</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-08T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361723#M23583</link>
      <description>&lt;P&gt;Thanks, that did the trick! I can't award you both with the answer unfortunately, but you get a point at least! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 15:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361723#M23583</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2018-02-08T15:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361724#M23584</link>
      <description>&lt;P&gt;Thank you! That helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 15:50:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361724#M23584</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2018-02-08T15:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361725#M23585</link>
      <description>&lt;P&gt;that don't work for me i have a buton like this (in the code source) :&lt;/P&gt;

&lt;P&gt;id="button_update" class="btn" data-set-token="run_check" data-value="true" style="background-color:#68E674;"&lt;/P&gt;

&lt;P&gt;and the js : equire([&lt;BR /&gt;
       'underscore',&lt;BR /&gt;
       'jquery',&lt;BR /&gt;
       'splunkjs/mvc',&lt;BR /&gt;
       'splunkjs/mvc/tableview',&lt;BR /&gt;
       'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;
   ], function(_, $, mvc, TableView) {&lt;/P&gt;

&lt;P&gt;$(document).ready(function () {&lt;BR /&gt;
          $("button_update").on("click", function (e) {&lt;BR /&gt;
             var mySearch = mvc.Components.get("toto");&lt;BR /&gt;
             mySearch.startSearch();&lt;BR /&gt;
          });&lt;BR /&gt;
      });&lt;/P&gt;

&lt;P&gt;});&lt;BR /&gt;
But the search never start any idea ?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361725#M23585</guid>
      <dc:creator>sandyBDF</dc:creator>
      <dc:date>2020-09-30T05:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a search job in JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361726#M23586</link>
      <description>&lt;P&gt;If the accepted answer doesn't work for you then you should post a new question describing your particular situation.&lt;/P&gt;</description>
      <pubDate>Sun, 31 May 2020 14:21:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-can-I-reference-a-search-job-in-JavaScript/m-p/361726#M23586</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-31T14:21:52Z</dc:date>
    </item>
  </channel>
</rss>

