The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using gs.sleep in a scoped application

dickhirsch
Mega Guru

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.

10 REPLIES 10

Matt Saxton - G
Kilo Guru

Hi D,



Try this



sleep(1000);



function sleep(ms) {


      var unixtime_ms = new Date().getTime();


      while(new Date().getTime() < unixtime_ms + ms) {}


}



-Matt


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


Indeed Tony,


on top of wasting processing cycles, it's instantiating a new Date object in each loop.



Cheers,


Lucas


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.