Delaying in Scheduled Job using gs.sleep() for 2 days

Yash47
Tera Contributor

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

5 REPLIES 5

Saurabh Gupta
Kilo Patron
Kilo Patron

The better option to use flow designer instead of a schedule job.

 

 


Thanks and Regards,

Saurabh Gupta

PFA

SaurabhGupta_0-1671820101303.png

 

 

 


Thanks and Regards,

Saurabh Gupta

OlaN
Giga Sage
Giga Sage

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

Yash47
Tera Contributor

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