Is it possible to change scope while in a script?

Tony28
Giga Contributor

There are situations within my organization's instances in which we need to clean up data that is spread out amongst multiple application scopes, and we find it very time consuming to manually switch between application scopes.

I had thought to have a fix script (or some other automation solution) to automate running through an encoded query of records to do things such as changing a bulk of update sets from complete to ignore. My question is: Is it possible to change application scope from within a scheduled job or fix script?

I've searched around docs and other community posts and haven't found an exact answer. 

Thank you!

1 ACCEPTED SOLUTION

Tony28
Giga Contributor

I decided to open a case with ServiceNow to get a direct answer. Unfortunately, according to them, there is no way to change scope within a script.

 

They suggested using script includes in different scopes and then calling them from within the fix script, but that doesn't exactly fit my need for what I'm trying to do. Maybe I'll try suggesting it for a future release!

 

Hopefully this provides some closure to some people who were searching like me.

View solution in original post

2 REPLIES 2

Tony28
Giga Contributor

I decided to open a case with ServiceNow to get a direct answer. Unfortunately, according to them, there is no way to change scope within a script.

 

They suggested using script includes in different scopes and then calling them from within the fix script, but that doesn't exactly fit my need for what I'm trying to do. Maybe I'll try suggesting it for a future release!

 

Hopefully this provides some closure to some people who were searching like me.

You can use the DevTools function RunScriptInScope() to run any script in any scope from any scope.

The DevTools app contains a truckload of reusable scripts and
features to support your app development.
Check this out:
https://www.wildgrube.com/servicenow-devtools