Search code examples
javascriptreportcognos

Create a scheduled report with a infinite JavaScript loop


I'm trying to create a new scheduled report and I've one doubt about it: How can I create a script on it with a loop that runs a function every 10 seconds? Something like:

var value = 1;
while(value > 0){
    setTimeout(function(){myFunction()},10000);
    value = value -1;
}

When I just run my report into the report studio (without schedule) this script executes successfully, but after the schedule it doesn't work anymore. Someone know why is this happening or have any other idea?

Thanks in advance.


Solution

  • Use setInterval instead of setTimeout.

    Also your while loop is not needed.

    Just use this instead: setInterval(myFunction, 10000);