Shamma Negi
Kilo Sage
Kilo Sage

Details

 

A scoped application doesn't honor direct use of "gs.sleep()" function in "Application scope" scripts.

 

Instructions or Steps

The "gs.sleep()" function can't be used in scoped application scripts, as this falls under the global scope. But to make use of this function follow the below process.

 

  • You can create a "script include" in the global scope and make sure the "Accessible from" is set to "All Application Scope"
  • Create a custom function in the script include and within that use "gs.sleep()"

         Example:

var SleepForScoppedApp = Class.create();
SleepForScoppedApp.prototype = {
    initialize: function() {},
    sleep: function(time) {
        gs.sleep(time);
    },
    type: 'SleepForScoppedApp'
};
  • Now call this function from any application scope scripts to make use of the "gs.sleep()" functionality. Make sure to use "global. <script>" format to call the function as this scripted include is created in global application

I read this support article today and got this useful information 

Supported ServiceNow Article: How to make use of gs.sleep() in a scoped application scripts - Support and Troubleshooting (service...

 

I will also cover the slowness caused by gs.sleep() in scrips in my next articles. Please follow for more updates on this.

 

Hope this helps.

I hope this article helpful. Please mark it as helpful and bookmark if you like it.

 

Regards,

Shamma

 

 

2 Comments