cross-scope access policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 06:59 PM
Hello, I ask for your help.
I added a business rule to the application and created a script to get the values of the tables of other applications.However, an error similar to the phrase below appears.
Access to api 'setValue(x_cdltd_loaner_req_loaner_request.state)' from scope 'x_cdltd_testing_ap' has been refused due to the api's cross-scope access policy
While looking for workarounds, I found a way to add a record to cross-scope privileges.
However, status is not changed to allowed. Does anyone know how to do it?
<script>
(function executeRule(current, previous /*null when async*/) {
// When closed complete is triggerd it also inactivates the task
var loanerRecs = new GlideRecord('x_cdltd_loaner_req_loaner_request');
loanerRecs.addQuery('state','!=',3);//not closed complete
loanerRecs.query();
while(loanerRecs.next()){
loanerRecs.setValue('state',3);
loanerRecs.update();
}
})(current, previous);
<error page>
- Labels:
-
Scoped App Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 07:17 PM
Hi
You should update the status to Allowed manually.
Mark my answer as HELPFUL / CORRECT if this help resolve your issue.
Regards,
Vamsi S

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 07:22 PM
There are couple ways to do this.
You can keep your code in script include (GLOBAL SCOPE) and call it from Business rule.
Example:
Business rule
(function executeRule(current, previous /*null when async*/) {
var scriptInclude = new loanerRequestUtil();
scriptInclude.loaner();
})(current, previous);
Script include
Name - loanerRequestUtil
Application - Global
Accessible from - All application scope
var loanerRequestUtil = Class.create();
loanerRequestUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
loaner: function(){
var loanerRecs = new GlideRecord('x_cdltd_loaner_req_loaner_request');
loanerRecs.addQuery('state','!=',3);//not closed complete
loanerRecs.query();
while(loanerRecs.next()){
loanerRecs.setValue('state',3);
loanerRecs.update();
},
type: 'loanerRequestUtil'
});
}
The other one was already mentioned by
Regards,
Muhammad
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 11:17 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 06:18 PM
Please define the cross Scope privilege. Read the following article Cross-scope privilege record | Servicenow Docs to understand it better. Application cross scope creation will fix this issue.
Muhammad