<?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 How to disable search run in js on page load? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482339#M31626</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I created a html-dashboard in which the user can choose a work station and then can click buttons for several machine faults. &lt;BR /&gt;
If a button is pressed, a search is started in js to write the fault, the time and if the fault is coming or going to a summary index.&lt;/P&gt;

&lt;P&gt;This is the js code from one button:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; mysearch1_K = new SearchManager({
            id: "button1_K",
            autostart: "false",
            search: mvc.tokenSafe('| makeresults | eval Störung="Störung1" | eval action="kommend" | eval Arbeitsplatz=tostring("$form.Arbeitsplatz$") | table _time Störung action Arbeitsplatz | addinfo | collect index=summary' )
        });
        $(".button1_K").on("click", function (){

            console.log(tokens.get("form.Arbeitsplatz"));


            //alert('Ausgeführt Störung 1 kommend');
            console.log("Störung1 kommend");


            //console.log(mysearch1_K.get("search"));
            mysearch1_K.startSearch();


            $(this).prop("disabled", true);

            $(".button1_G").prop("disabled", false);

        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the html "code":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;div id="row1" class="dashboard-row dashboard-row1"&amp;gt;
        &amp;lt;div id="panel2" class="dashboard-cell" style="width: 50%;"&amp;gt;
            &amp;lt;div class="dashboard-panel clearfix"&amp;gt;

                &amp;lt;div class="panel-element-row"&amp;gt;
                    &amp;lt;div id="element2" class="dashboard-element html" style="width: 100%"&amp;gt;
                        &amp;lt;div class="panel-body html"&amp;gt;
                                &amp;lt;div&amp;gt;
                                    &amp;lt;button class="btn btn-primary button1_K btnKommend btnST"&amp;gt;St&amp;amp;#246;rung 1 kommend&amp;lt;/button&amp;gt;
                                    &amp;lt;p&amp;gt;Beschreibung Störung&amp;lt;/p&amp;gt;
                                &amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You see that i have set the searchmanager property "autostart = false" in the code. But it runs every search (for 14 buttons like the code above) when loading the page. &lt;BR /&gt;
Did I miss something?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2019 08:27:52 GMT</pubDate>
    <dc:creator>haph</dc:creator>
    <dc:date>2019-09-16T08:27:52Z</dc:date>
    <item>
      <title>How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482339#M31626</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I created a html-dashboard in which the user can choose a work station and then can click buttons for several machine faults. &lt;BR /&gt;
If a button is pressed, a search is started in js to write the fault, the time and if the fault is coming or going to a summary index.&lt;/P&gt;

&lt;P&gt;This is the js code from one button:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; mysearch1_K = new SearchManager({
            id: "button1_K",
            autostart: "false",
            search: mvc.tokenSafe('| makeresults | eval Störung="Störung1" | eval action="kommend" | eval Arbeitsplatz=tostring("$form.Arbeitsplatz$") | table _time Störung action Arbeitsplatz | addinfo | collect index=summary' )
        });
        $(".button1_K").on("click", function (){

            console.log(tokens.get("form.Arbeitsplatz"));


            //alert('Ausgeführt Störung 1 kommend');
            console.log("Störung1 kommend");


            //console.log(mysearch1_K.get("search"));
            mysearch1_K.startSearch();


            $(this).prop("disabled", true);

            $(".button1_G").prop("disabled", false);

        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the html "code":&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;div id="row1" class="dashboard-row dashboard-row1"&amp;gt;
        &amp;lt;div id="panel2" class="dashboard-cell" style="width: 50%;"&amp;gt;
            &amp;lt;div class="dashboard-panel clearfix"&amp;gt;

                &amp;lt;div class="panel-element-row"&amp;gt;
                    &amp;lt;div id="element2" class="dashboard-element html" style="width: 100%"&amp;gt;
                        &amp;lt;div class="panel-body html"&amp;gt;
                                &amp;lt;div&amp;gt;
                                    &amp;lt;button class="btn btn-primary button1_K btnKommend btnST"&amp;gt;St&amp;amp;#246;rung 1 kommend&amp;lt;/button&amp;gt;
                                    &amp;lt;p&amp;gt;Beschreibung Störung&amp;lt;/p&amp;gt;
                                &amp;lt;/div&amp;gt;
                        &amp;lt;/div&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You see that i have set the searchmanager property "autostart = false" in the code. But it runs every search (for 14 buttons like the code above) when loading the page. &lt;BR /&gt;
Did I miss something?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 08:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482339#M31626</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2019-09-16T08:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482340#M31627</link>
      <description>&lt;P&gt;Found the solution or cause by myself.&lt;/P&gt;

&lt;P&gt;When declaring the Searchmanager with the search string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch1_K = new SearchManager({
             id: "button1_K",
             autostart: "false",
             search: mvc.tokenSafe('| makeresults | eval Störung="Störung1" | eval action="kommend" | eval Arbeitsplatz=tostring("$form.Arbeitsplatz$") | table _time Störung action Arbeitsplatz | addinfo | collect index=summary' )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the search is executed even with 'autostart: "false"'. &lt;BR /&gt;
If I don't specify the search string in the declaration, the search is not executed:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch1_K = new SearchManager({
             id: "button1_K",
             autostart: "false"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Sep 2019 11:35:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482340#M31627</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2019-09-24T11:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482341#M31628</link>
      <description>&lt;P&gt;Hi Haph,&lt;/P&gt;

&lt;P&gt;I'm facing the same issue. can you tell me if we can not include search in searchManager then where else we can include  it.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 05:18:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482341#M31628</guid>
      <dc:creator>rishavvaidya</dc:creator>
      <dc:date>2020-01-30T05:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482342#M31629</link>
      <description>&lt;P&gt;Hi rishavvaidya,&lt;/P&gt;

&lt;P&gt;you first declare the searchmanager like in my answer above. &lt;BR /&gt;
Then, when you want to execute the search you first set the search string and then start the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; // Setting search string
searchST.settings.set("search", mvc.tokenSafe('| makeresults 1| eval Störung="'+ St +'" | eval action="kommend" | eval temp=split(tostring("$form.Arbeitsplatz$"),"_") | eval Arbeitsplatz=mvindex(temp,0) | eval Linie=mvindex(temp,1) | fields - temp | table _time Störung action Arbeitsplatz Linie | collect index=summary' ));  

// Starting search
searchST.startSearch();
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if it is important that the search &lt;EM&gt;exactly&lt;/EM&gt; executed once (in my use case because the search writes a button press into the index and I want to count the presses and multiply search executions results in multiple indexed button presses instead of one) then you have to add the following after the xxx.startSearch();:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchST.finalize();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jan 2020 07:42:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/482342#M31629</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-01-30T07:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/534723#M36460</link>
      <description>&lt;P&gt;HI - I am new to java script can you post the full file please as i am having issues&amp;nbsp; understanding the before and after.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 16:46:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/534723#M36460</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2021-01-04T16:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable search run in js on page load?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/565782#M46488</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think you could publish the fill javascript for your answer, please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 11:57:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-disable-search-run-in-js-on-page-load/m-p/565782#M46488</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2021-09-03T11:57:40Z</dc:date>
    </item>
  </channel>
</rss>

