Shamma Negi
Kilo Sage

Avoid using gs.sleep() in any script because it does not release session and will cause delays, and add logs to the script whenever gs.sleep() has to be used.

 

Rather use the below server-side scripting:

 

Script#1

Add 1000ms in current date/time and run loop till 1000ms from now

 

sleep(1000);

function sleep(ms) {

      var unixtime_ms = new Date().getTime();

      while(new Date().getTime() < unixtime_ms + ms) {}

 

}

 

Script#2

 

Add delay of 5 seconds to the script

 

var when = new GlideDateTime();
var delay = new GlideTime();
delay.setValue("00:00:05");
when.add(delay);

 

 

Hope it helps.

I hope this article helpful. Please mark it as helpful and bookmark if you like it.

 

Regards,

Shamma Negi

7 Comments