Can i make a timeout in Scheduled script?

Alex Buliga
Kilo Guru

Hi everyone, my question might be in the wrong category, pls moderators - move it in the right place.

 

I'm having a scheduled script and as we all know - its executing his script on server side.

 

var evt = new GlideRecord('sysevent');
    evt.initialize();

evt.insert();

//i need a timeout here for about 15 sec

var emails_GR = new GlideRecord('sys_email');

The thing is that after a sysevent is inserted i want to make a timeout, for about 15 sec and after that "quering'" sys_email. 

Any chances to realize it?

Thanks 

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

You can try using gs.sleep(5000) // 5 seconds but not a good practice to do

Regards
Harish

i'll try it before in bg script

i noticed that demo code will print all the info after 5 seconds on screen in bg script, instead sequentially. How correct is that?

gs.print('1')
gs.print('2')
gs.print('3')
gs.print('4')
gs.sleep(5000)
gs.print('5')

 

Chandu Telu
Tera Guru
Tera Guru

Hi , 

setTimeout is client side Javascript. You use the gs.sleep() but this not best practice

There is good discussion happened check the below link

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

 

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,