- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 09:39 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 04:25 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 03:31 AM
On server scripts you can use the global gs.sleep method to pause the script in milliseconds
gs.sleep(590000); //590 seconds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 04:16 AM
Just as a warning on this - it can be dangerous if that script will run concurrently.
gs.sleep will keep control of the thread, and on smaller instances (example with only two app nodes) you can quickly run out of threads and cause an instance outage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2024 08:19 AM
This script pauses the entire instance. I pasted it in my widget server script and everybody on the team can't code anything in the instance for 10 minutes lol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 04:25 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader