Add sleep or delay in your script for global + scoped app
New article articles in ServiceNow Community
·
Dec 28, 2024
·
article
Many a times there is a need to add some delay in your script in server side.
Below script will work in both global + scoped app. The value passed is duration value. I passed 10 seconds in duration format. It can be customized as per your requirement.
Script:
gs.info('Before delay->' + new GlideDateTime().getValue());
var now = new GlideDateTime();
while(GlideDateTime.subtract(now, new GlideDateTime()) < "1970-01-01 00:00:10") {
// loop for 10 seconds}
gs.info('After delay->' + new GlideDateTime().getValue());
Output: Global scope
Output: Scoped app
View original source
https://www.servicenow.com/community/service-operations-workspace/add-sleep-or-delay-in-your-script-for-global-scoped-app/ta-p/3136917
Ankur Bawiskar