Cannot call script includes from scoped applications

Ulf Cederholm
Tera Expert

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'
});

find_real_file.png

1 ACCEPTED SOLUTION

Ulf Cederholm
Tera Expert

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.

View solution in original post

6 REPLIES 6

Ulf Cederholm
Tera Expert

Thanks for the replies.

I've tried on both onLoad and OnChange scripts. Works in global but not in scoped apps.

gs.log works fine with global client script. But tried gs.info as well no difference I'm afraid.

I think the solution is as Mahendra mentions, using 'global.<script_include>' to let the script no where to look for the scrip include.

I have tried this before however and could not get it to work. I get the errors below.

On client side:

Execute operation on script include 'LUCallableFromScopedAppTest' from scope '<scoped_app>' was denied. The application '<scoped_app>' must declare a cross scope access privilege. Please contact the application author to update their privilege requests.

On server side in error log:

Script: LUCallableFromScopedAppTest not found in scope: x_scoped_app, and HTTP Processor class not found: com.glide.processors.xmlhttp.LUCallableFromScopedAppTest: no thrown error

 

Looking at ServiceNow documentation it mentions that script includes with a 'caller access' field (hidden) value of 'none' should be available everwhere if 'accessible from' is set to 'All application scope'. And as far as I can tell the default value is indeed 'none'.

I've tried to follow the directions below but couldn't get it to work. No requests or invalidations in 'application restricted caller access privileges' for the scoped app in question for me to handle.

https://community.servicenow.com/community?id=community_blog&sys_id=ce28d5b8db690c5c5129a851ca961999

Ulf Cederholm
Tera Expert

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.