Implement timeout in Run Server Side Script

ayano
Giga Guru

Is it possible to write a script in "Run Server Side Script" that will execute a timeout for 590 seconds?
Like this timeout in the picture.

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ayano 

you can use this in the run server side script step to pause for the seconds

(function executeStep(inputs, outputs, stepResult, timeout) {

        var secondsValue = 590;
	var seconds = parseInt(secondsValue, 10) * 1000;
	var start = parseInt(new Date().getTime()) + seconds;
	while(start>parseInt(new Date().getTime())){
		// do nothing
	}
	stepResult.setOutputMessage('This step gave sleep of 590 seconds');
	stepResult.setSuccess();

}(inputs, outputs, stepResult, timeout));

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Hi Ankur san,

Thank you for the information.

Did you succeed with this script?

 

Thanks and Regards,

@ayano 

I have not tested this recently.

But when I used something similar few months back it did work

Regards
Ankur

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