Need to add delay for Business rule in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:03 AM
Hi experts,
Need to add delay to the business rule in scoped application. using the business rule I am creating the records before creating the records it should wait for some time. for that wait I used the below scripts.
script1:
var when = new GlideDateTime();
var delay = new GlideTime();
delay.setValue("00:02:00");
when.add(delay);
script 2:
gs.sleep(10000); //10 secs
I tried both scripts on Business rules. Please suggest the script to pause BR on scoped application.
Thanks,
Pavan
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:13 AM
Hello
In scoped app, gs.sleep() is not allowed you can use this to use some delay
ms means milliseconds here
function sleep(ms) {
var endSleep = new GlideDuration().getNumericValue() + ms;
while ( new GlideDuration().getNumericValue() < endSleep) {
//wait
}
return;
}
Please Mark âś… Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:14 AM
Hi,
this works in scoped app
var seconds = parseInt(10, 10) * 1000; // 10 seconds delay
var start = parseInt(new Date().getTime()) + seconds;
while(start>parseInt(new Date().getTime())){
// do nothing
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:24 AM
@pavan
I have shared solution here 2 years ago
How to create a delay in record creation
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 01:41 AM
Thank you for marking my response as helpful.
Please mark appropriate response as correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader