The CreatorCon Call for Content is officially open! Get started here.

With business rules Is it possible to delay the execution of the script by about 30 seconds?

SS64
Tera Contributor

With business rules Is it possible to delay the execution of the script by about 30 seconds?

20 REPLIES 20

Would you like to see if it's been 30 seconds?

I tried to run it, but in less than 30 seconds
I think the business rules are working soon.

Hi,

even if BR runs the event would be triggered immediately but it would be processed only after the time you have given i.e. 30 seconds in above case

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Gaurav Shirsat
Mega Sage

Hi SS

try using the gs.sleep(<seconds>);

or you can perform this by your own code also.

function delayExecute(time){ 

  var delay1 = new GlideDateTime().getNumericValue(); 

  var delay2 = new GlideDateTime().getNumericValue(); 

  var difference = delay2 - delay1; 

  while(difference < time){ 

      delay2 = new GlideDateTime().getNumericValue(); 

      difference = delay2 - delay1; 

  } 

},

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

thank you

If I want to delay 30s,

gs.sleep(30); light?

after 30s,BR is restard job?

The SN Nerd
Giga Sage
Giga Sage

This sounds like a perfect use case for Flow, which runs Asynchronously (usually about 30 seconds after the trigger).

You can wait in the Flow or just rely on the asynchronous nature of the flow.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022