Delaying in Scheduled Job using gs.sleep() for 2 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 08:41 AM
Hello,
I want to use conditional scheduled job script ( to run on every 2nd and 4th Friday of each month)
after condition returns true,
want to use some code and after that have to wait for 2 days , I am using gs.sleep(172800000); will it create any impact?
If yes then what should I use instead of gs.sleep();
I am not using gs.eventQueueScheduled(); because the parameters which we have to pass for that , we will get those parameters after delaying for 2 days.
***NOTE : after that gs.sleep(); I have to use some code in same scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 10:21 AM
The better option to use flow designer instead of a schedule job.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 10:28 AM
PFA
Thanks and Regards,
Saurabh Gupta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 10:22 AM
Hi,
What's the reason for the waiting?
Would it be possible to run the script, and then start another script two days after?
In general you should avoid using gs.sleep()
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0747610
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2023 12:49 AM
Hello,
Reason for waiting is :
I have to run some script which triggers an notification of survey email: and I have to wait for users to respond that survey mail for 2 days and depending on responses I have send another notification to users who didn't responded to that survey and again I have to wait for their responses again I have to send a FINAL REMINDER and after waiting for 1 day again I have to do some changes automatically.
This is the reason why I have to wait for 2 days then again 2 days and again 1 day