Hi
I have a splunk query(with javascript) which i would like to run multiple times using javascript loop. Please find below code
`dupcount1=splunkjs.mvc.Components.get("search8");
dupcount1.data("results").on("data", function(results) {
if (DupData == true) {
var dupcount = results._data['rows'][0][0];
var i;
var batchsize = 10
for (i = 0; i <= 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;
}
});`
based on value of i i am setting token and start search. when (i==0) the search runs fine and everything completes graciously. Issue i am facing is when (i !=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 else loop.
Thanks in advance.
Probably something wrong with the instantiation / initialization of search9
, as opposed to search4
which is working.
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 search9
is a typo. If search9
is a typo, then you should also check the line with search8
.
HI @DalJeanis
Thanks for replying. i will clear out the air here.
please let me know if you need more explainations.
Thanks