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

Set the waiting time in the script.

bonsai
Mega Sage

※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);
    }
}
1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

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

View solution in original post

5 REPLIES 5

Maik Skoddow
Tera Patron
Tera Patron

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

solved!
Thank you! !!

Hitoshi Ozawa
Giga Sage
Giga Sage

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. 

https://community.servicenow.com/community?id=community_question&sys_id=7da0b3a4dbaf08d0d82ffb243996...

ServiceNow has events that can be scheduled and can be caught.

https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_le...

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.

 

Adjustment of the number of concurrent transactions - Service Management - Question - ServiceNow Com...