The Now Platform® Washington DC release is live. Watch now!
‎05-28-2015 03:39 AM
Hi,
I'm trying to use gs.sleep (1000) in a scoped application and I keep getting an exception:. com.glide.script.fencing.MethodNotAllowedException: Function sleep is not allowed in scope "xxx"
I've tried "GlideSystem.sleep(1000); " but get a similar exception: java.lang.SecurityException: GlideSystem is not allowed in scoped applications exception.
Anyone have any hints.
Thanks,
D.
‎05-28-2015 07:30 AM
Hi D,
Try this
sleep(1000);
function sleep(ms) {
var unixtime_ms = new Date().getTime();
while(new Date().getTime() < unixtime_ms + ms) {}
}
-Matt
‎05-28-2015 08:06 AM
Hi Matt,
Is it worth mentioning that the sleep function you define is quite busy?
I suppose that with a parameter of 1000 it will spin round a few times for 1 sec and then exit.
Once deployed it could be called with a large number to specify say 1 hour.
In that case might it use a lot of resources?
Not sure really hence my question.
Best Regards
Tony
‎05-28-2015 08:13 AM
Indeed Tony,
on top of wasting processing cycles, it's instantiating a new Date object in each loop.
Cheers,
Lucas
‎05-28-2015 08:26 AM
I'm assuming that it is might be more of a permissions problem connected with my use of an scoped application. What is interesting is that the sleep function isn't even listed in the Scoped Glide System wiki entry.
D.