<?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: Splunk Query using startSearch() is not running in  a loop with token in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303359#M19339</link>
    <description>&lt;P&gt;HI @DalJeanis &lt;/P&gt;

&lt;P&gt;Thanks for replying. i will clear out the air here.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I am using a for loop and where variable &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; decides the batch size &lt;/LI&gt;
&lt;LI&gt;inside loop there is if condition, if satified one condition it starts search4, till now everythings work great.&lt;/LI&gt;
&lt;LI&gt;In else Condition, i am triggering  start search9 where the value of  variable &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; is being used to set a token used in search &lt;/LI&gt;
&lt;LI&gt;so for e.g &lt;/LI&gt;
&lt;/UL&gt;

&lt;OL&gt;
&lt;LI&gt; if value of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; =1 , i am setting token value &lt;STRONG&gt;&lt;EM&gt;token1=400&lt;/EM&gt;&lt;/STRONG&gt;  and &lt;STRONG&gt;&lt;EM&gt;token2= 200&lt;/EM&gt;&lt;/STRONG&gt; and triggering search using &lt;STRONG&gt;&lt;EM&gt;startSearch()&lt;/EM&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;if value of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; =2 , i am setting token value &lt;STRONG&gt;&lt;EM&gt;token1=600&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;token2=400&lt;/EM&gt;&lt;/STRONG&gt; and riggering search using &lt;STRONG&gt;&lt;EM&gt;startSearch()&lt;/EM&gt;&lt;/STRONG&gt;. and so on till loop is valid. &lt;/LI&gt;
&lt;/OL&gt;

&lt;UL&gt;
&lt;LI&gt;now ideally in else loop, if there are 3 values of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; there should be 3 instances of token and search JOB, instead i always and only get last instance of search9. &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;please let me know if you need more explainations. &lt;/P&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 10:20:41 GMT</pubDate>
    <dc:creator>nawneel</dc:creator>
    <dc:date>2017-11-27T10:20:41Z</dc:date>
    <item>
      <title>Splunk Query using startSearch() is not running in  a loop with token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303357#M19337</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
I have a splunk query(with javascript)  which i would like to run multiple times using javascript loop. Please find below code &lt;/P&gt;

&lt;P&gt;`dupcount1=splunkjs.mvc.Components.get("search8");&lt;BR /&gt;
dupcount1.data("results").on("data", function(results) {&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if (DupData == true) {
    var dupcount = results._data['rows'][0][0];
    var i;
    var batchsize = 10
    for (i = 0; i &amp;lt;= dupcount / batchsize; i++) {

        if (i == 0) {
            defaultTokenModel.set("head1", batchsize);

            search4.startSearch();

        } else {
            defaultTokenModel.set("head2", batchsize * (i + 1));
            defaultTokenModel.set("tail", batchsize * i);

            search9.startSearch();

        }
    }

    return true;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;});`&lt;/P&gt;

&lt;P&gt;based on value of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt;  i am setting token and start search. when (&lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt;==0) the search runs fine and everything completes graciously. Issue i am facing is when (&lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; !=0)  than only for last loop job is triggered. what i would like is that , if there are 9 loops, 9 searches should be triggered. i am not able to understand why only last search is starting in &lt;STRONG&gt;&lt;EM&gt;else&lt;/EM&gt;&lt;/STRONG&gt; loop. &lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 14:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303357#M19337</guid>
      <dc:creator>nawneel</dc:creator>
      <dc:date>2017-11-24T14:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query using startSearch() is not running in  a loop with token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303358#M19338</link>
      <description>&lt;P&gt;Probably something wrong with the instantiation / initialization of &lt;CODE&gt;search9&lt;/CODE&gt;, as opposed to &lt;CODE&gt;search4&lt;/CODE&gt; which is working.  &lt;/P&gt;

&lt;P&gt;Since you didn't show us that portion of the code, we aren't going to be able to tell you exactly what you did wrong, unless &lt;CODE&gt;search9&lt;/CODE&gt; is a typo. If &lt;CODE&gt;search9&lt;/CODE&gt; &lt;STRONG&gt;&lt;EM&gt;is&lt;/EM&gt;&lt;/STRONG&gt; a typo, then you should also check the line with &lt;CODE&gt;search8&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Nov 2017 03:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303358#M19338</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-25T03:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Query using startSearch() is not running in  a loop with token</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303359#M19339</link>
      <description>&lt;P&gt;HI @DalJeanis &lt;/P&gt;

&lt;P&gt;Thanks for replying. i will clear out the air here.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I am using a for loop and where variable &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; decides the batch size &lt;/LI&gt;
&lt;LI&gt;inside loop there is if condition, if satified one condition it starts search4, till now everythings work great.&lt;/LI&gt;
&lt;LI&gt;In else Condition, i am triggering  start search9 where the value of  variable &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; is being used to set a token used in search &lt;/LI&gt;
&lt;LI&gt;so for e.g &lt;/LI&gt;
&lt;/UL&gt;

&lt;OL&gt;
&lt;LI&gt; if value of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; =1 , i am setting token value &lt;STRONG&gt;&lt;EM&gt;token1=400&lt;/EM&gt;&lt;/STRONG&gt;  and &lt;STRONG&gt;&lt;EM&gt;token2= 200&lt;/EM&gt;&lt;/STRONG&gt; and triggering search using &lt;STRONG&gt;&lt;EM&gt;startSearch()&lt;/EM&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;if value of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; =2 , i am setting token value &lt;STRONG&gt;&lt;EM&gt;token1=600&lt;/EM&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;EM&gt;token2=400&lt;/EM&gt;&lt;/STRONG&gt; and riggering search using &lt;STRONG&gt;&lt;EM&gt;startSearch()&lt;/EM&gt;&lt;/STRONG&gt;. and so on till loop is valid. &lt;/LI&gt;
&lt;/OL&gt;

&lt;UL&gt;
&lt;LI&gt;now ideally in else loop, if there are 3 values of &lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;&lt;/STRONG&gt; there should be 3 instances of token and search JOB, instead i always and only get last instance of search9. &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;please let me know if you need more explainations. &lt;/P&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 10:20:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Splunk-Query-using-startSearch-is-not-running-in-a-loop-with/m-p/303359#M19339</guid>
      <dc:creator>nawneel</dc:creator>
      <dc:date>2017-11-27T10:20:41Z</dc:date>
    </item>
  </channel>
</rss>

