- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 06:42 PM
※This is the Paris version.
I'm using the script below to set the wait time.
However, this method seems to be CPU-intensive.
Does anyone know how to set an efficient wait time?
The script will be used in the job schedule.
function sleepe_timer() {
sleepe(30000);
function sleepe(a) {
var startMsec = new Date();
while (new Date() - startMsec < a);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 06:53 PM
Hi
you can use gs.sleep(milliseconds). Please note that you can only use it in the global scope but not in a custom scope.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 06:53 PM
Hi
you can use gs.sleep(milliseconds). Please note that you can only use it in the global scope but not in a custom scope.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:01 PM
solved!
Thank you! !!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:17 PM
FYI, sleep can be used in sample codes but as Ankur replied in the following thread, gs.sleep() is not recommended to be used in production.
ServiceNow has events that can be scheduled and can be caught.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 09:48 PM
thank you for your answer.
For example, isn't it recommended to use it when you want to check the record status every second?
I'm using it in the script in the question below.