Background scripts are always run in global scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 10:00 PM
Experience of running background scripts is not the same in VS Code vs Instance (Scripts - Background)
While VS Code status bar shows the current scope, Background Script always runs in rhino.global scope, making scoped scripts untestable. For example, I cannot use deleteMultiple on a scoped table, obviously.
Is scope even supported?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 10:22 PM
Hi Krishna,
you can use scheduled job to execute your scripts in scoped app instead of background scripts
Background scripts are not recommended; they can just be used to get some information etc but not to be used to update multiple records or delete multiple records
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 10:30 PM
deleteAll was just an example. Issue is about option to set scope which is available on instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 12:59 AM
The Background script runner in the extension works in tandem with the active application.
So you can run the Background scripts either in
- Global scope
- Current application scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 02:12 AM
Okay, I guess the problem statement is unclear.
When I use either
- Run Background Script - Current (OR)
- Run Background Script - Global (OR)
menus, the script is always running in Global scope.
My current scope was set to an Application when I opened a file from it in VS Code and I can see it on the status bar.