Trying to set a delay in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 09:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 09:08 AM
You can use below code for sleep function
- /* time is in milliseconds - this is essentially a "sleep" function */
- wait: function(time){
- var t1 = new GlideDateTime().getNumericValue();
- var t2 = new GlideDateTime().getNumericValue();
- var duration = t2 - t1;
- while(duration < time){
- t2 = new GlideDateTime().getNumericValue();
- duration = t2 - t1;
- }
- },
from here: gs.sleep() in scoped application?
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 09:34 AM
it is in a scoped application yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 09:38 AM
sleep cannot be used in scoped applications.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2020 09:41 AM
Create a Script Include in Global Scope, Accessible from All AplicationScopes and use below code
var MyGlobalScopeUtils = Class.create();
MyGlobalScopeUtils.prototype = {
initialize: function() {
},
/** Wrapper for gs.sleep
*
* @param {Integer} duration in ms
*/
sleep: function (duration) {
gs.sleep(duration);
},
type: 'MyGlobalScopeUtils'
};
In your scoped scripts you can use
var globalUtils = new global.MyGlobalScopeUtils(); //
globalUtils.sleep(1000);
Regards,
Sachin