gs.sleep() in scoped application?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2015 05:51 AM
Hi,
gs.sleep(0 function is not working in scoped application? Is there any workaround?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2015 10:43 AM
Hi Akash,
You cannot use sleep in Scoped Apps. You shouldn't even use it in non-scoped apps.
There is no work-around. If you need to wait for a condition, you need to factor your code to be asynchronous and use callbacks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2017 05:27 AM
Here's my workaround:
/* 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;
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 07:57 AM
I'm currently trying to use this workaround. Can someone point me in the right direction on where to place this wait function? Do I place it within the Script Include and then call it on the Client side so it awaits that response?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 10:29 PM
Please check if you can use retry policy. you can set time interval as well as no of times request will be called in case of any condition like time out etc