- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 07:08 AM
I attempted to follow this article below, but I am not executing it correctly
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0962370
This is what I have below based on the article
1) Should I put the actual time I need in the (time) option for the script include or leave this as is?
2) How do I call the function using global.<script>? I assumed this meant using the run server-side script in the ATF
The step passes but it is not actually delaying the steps so something needs to be changed.
Goal: I want to add a 2 minute delay between updating a record step and verifying the state for a RITM step using the gs sleep function in a scoped application
I need an example of using this KB's guidance in an ATF so I can see how to actually achieve the desired results.
Thanks a bunch
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:17 AM
I was able use this in the Run server side script and it worked
2000 is the delay time so for 2 minutes replace 2000 with 120000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 07:22 AM
Hi @Latoya ,
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...
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:02 AM
Thanks for the response but as I mentioned, I am aware of the KB article and included it in my original post. The issues is executing it properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 08:17 AM
I was able use this in the Run server side script and it worked
2000 is the delay time so for 2 minutes replace 2000 with 120000