
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 05:24 AM
I have a simple script include that I use as test. I'm trying to call the script from a client script in any of our scoped applications, But no matter what I try no log entry is generated in 'Script Log Statements'. So it look like the script include isn't called at all. Everything works just fine though from any global client scripts.
As far as I know it should work? What the obvious thing I'm missing? Anyone have any ideas?
Client script code I'm testing with:
var ga = new GlideAjax('LUCallableFromScopedAppTest');
ga.addParam("sysparm_name", "checkIfLoggedInUserHasRoleITIL");
ga.getXML(getResponse);
function getResponse(response) {
//Nothing
}
Script Include:
var LUCallableFromScopedAppTest = Class.create();
LUCallableFromScopedAppTest.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkIfLoggedInUserHasRoleITIL: function() {
gs.log('UlfC [LUCallableFromScopedAppTest] [checkIfLoggedInUserHasRoleITIL] [Script Include] [' + gs.getUserID() + ' has ITIL role <IS> ' + gs.hasRole('itil') + ']');
return gs.hasRole('itil');
},
type: 'LUCallableFromScopedAppTest'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 11:00 PM
I may have solved the issue. As mentioned in the article regarding 'cross scope access privilege' you should go to 'Application Restricted Caller Access Privileges' and find any requests there from the scoped app to access global. However I could not find any. But, I could find them in 'Application Cross-Scope Access'.
Here I could change the custom application entry and the field 'Runtime Access Tracking'. Default seems to be 'Enforcing' and changing this to '--None--' (and perhaps 'Tracking' as well) grants the scoped app access to the script include in glodal (using global.<script_include>). I'll have to check some more, but at least my test scripts all work now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 05:30 AM
Hi,
Are you calling client script on change or onload? add alert message and check whether it is getting called
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 05:33 AM
Hello,
Please check with below change
var ga = new GlideAjax('global.LUCallableFromScopedAppTest');
ga.addParam("sysparm_name", "checkIfLoggedInUserHasRoleITIL");
ga.getXML(getResponse);
function getResponse(response) {
//Nothing
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 05:52 AM
Also in your gs.log there is I think some issue:
gs.log('UlfC [LUCallableFromScopedAppTest] [checkIfLoggedInUserHasRoleITIL] [Script Include] [' + gs.getUserID() + ' has ITIL role <IS> ' + gs.hasRole('itil') + ']');
The itil in inside ' single quote not sure if that can cause an issue
Please check once with below log updated using " double quotes
gs.log("UlfC [LUCallableFromScopedAppTest] [checkIfLoggedInUserHasRoleITIL] [Script Include] [" + gs.getUserID() + " has ITIL role <IS> " + gs.hasRole('itil') + "]");
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 06:16 AM
Hi,
Can you try different logging methods like gs.info instead of gs.log
It will work.
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar