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:14 AM
Hi pavan,
1.) You can try the Async business rule
2.) You can try the below code as well, ms is milliseconds
For reference try
function sleep(ms) {
var endSleep = new GlideDuration().getNumericValue() + ms;
while ( new GlideDuration().getNumericValue() < endSleep) {
//wait
}
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:21 AM
HI,
It's not a best practice to use sleep and delay in scripts, instead make use of scheduled event.