261
Views
2
Comments
Solved
setInterval goes faster every time it gets called
Service Studio Version
11.52.7 (Build 60395)

I have the following "FetchUsers" client action that gets called on the OnReady event of the screen.


I want this Refresh GetUser to loop every few seconds, so the Javascript is the following 


This makes the interval go faster every time it gets called again, so after googling a few minutes I found that I should clear the interval in the same function loop, like this 



But this is not working, every time the functions loops, it goes faster than before, making it unsustainable, how should I clear the interval in order for this to work? 

UserImage.jpg
Swami Gallardo
Solution

I just found out. setInterval set ups a recurring timer, so I was creating a new loop every time I called it again.

I had to use setTimeout instead. 



2020-08-31 05-04-40
Rahul Jain

Hello Swami ,

Please use below code and find attached oml file

setTimeout(function () {

    $actions.Action1();


}, 1000);


Thanks 

Rahul Jain

setInterval.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.