Clear SetInterval On Block, and block is on a scree
Application Type
Service Studio Version
11.53.10 (Build 61057)


I have a JavaScript SetInterval function which runs a Auto save functionality 

and it is all on a block, Actually I have a text field  wich saves the input in every 10 seconds,

so here I use a JS which triggers a action in  a interval of 10 seconds

Now Data is successfully saving, but what I have to do now, I have a Button On which I have to clear this Interval or remove this. so that it will stop execution. The issue is when On the same action My block will hide once the execution is completed, but even it is hidden, but the Javascript code keeps running in a background because block exixt on a screen. Please help


Hi Hiba,

On the button click, make sure to clear the created interval (i.e. timer) by executing the clearInterval method. 

Note that, you will have to pass the id returned from the setInterval method invocation, to the clearInterval method as an argument.


Based on your implementation you will have to store the interval variable value (i.e. id returned from setInterval() method invocation ) in a local variable and pass the same value as the argument to the clearInterval method.

I hope this helps you!

Kind regards,

Benjith Sam

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