Hey Guyz,
I am trying to do a flow.
When the page is ready,
I need to trigger an action which will run every 5 seconds
But I need to stop that action after 60 seconds.
This is the flow I have created.
In on Ready action.
I have used the two javascript.
The set timeout will run the TimeExpired action after some seconds (Input Parameter Ex:60s)
The set interval will run the RefressData action every 5 seconds. the action follows
This is the TimeExpired action
I am clearing the interval in this action.
But my problem is, the Refresh Data action is still running.
How to stop that?
Thanks,
Keerthi
One solution is to store TimerHandle to add Outsystems screen local variable and set it like this:
Then screen OnDestroy (or other needs) clear it like this:
OnDestroy is important to remember to make this so it wont be forgotten hanging there.
Hi Keerthi,
The easiest solution is to create 2 timers, as you did. One running every 5s, and one running 60s.
Like Esa said, store the handle of the 2 timers, when the 60s timer run, clear the interval of the first one, something like
var periodTimer = setInterval($action.RefreshData, 5000);
setTimeout(function(timer){clearInterval(timer)}, $parameters.TimeInSeconds * 1000, periodTimer);
Hope this helps,
RG
Hi Esa,
I know this is an old issue but i'm hoping you could tell me of what type "TimerHandle' is?
Thanks!
Hi Liesbeth! I am sorry, I just noticed your question.Id is numeric type as you can find e.g. from here: https://developer.mozilla.org/en-US/docs/Web/API/setIntervalSo in Outsystems you can use Integer