Global system script includes not available from scopes

john_roberts
Mega Guru

There are many system provided script includes that are not accessible from custom scopes. Even though they are in the global scope they are blocked because the "accessible from" value is set to "this scope only". This is going to create a huge issue and drive everyone to make a lot of changes to system scripts.

First ones I came across were commonly used, JSUtil and TableUtils.

Changing the "accessible from" resolves the issue. Platform wide system scripts should be set to be available in all scopes or just not have the setting apply if scope is global.

"Illegal access to private script include TableUtils in scope rhino.global being called from scope x_...."

David Gatley

24 REPLIES 24

xMTinkerer
Giga Expert

Darn, I need to add XMLHelper to this list. This is a very nice utility that will convert XML to JSON. I'm not sure why this utility is not available outside the global scope.


XML Helper is available in the scoped api you just need to initiate with global in front. So for XMLHelper it should look like



var xmlhelper = new global.XMLHelper();



http://wiki.servicenow.com/index.php?title=Scripting_in_Scoped_Applications#Calling_Script_Includes


Checkout section 3.2.3


Darrin,


  Have you tried that while in a scope? When using it in the "Scripts - Background" in a non global scope, I get this:



Evaluator: java.lang.SecurityException: Illegal access to private script include XMLHelper in scope rhino.global being called from scope x_xma_testing6


  Caused by error in script at line 1



==>   1: var xmlhelper = new global.XMLHelper();



Evaluator: java.lang.SecurityException: Illegal access to private script include XMLHelper in scope rhino.global being called from scope x_xma_testing6


  Caused by error in script at line -1


Background message, type:error, message: Illegal access to private script include XMLHelper in scope rhino.global being called from scope x_xma_testing6




This was the script I tried:


var xmlhelper = new global.XMLHelper();


Yes I have with no issues. Did you make sure to add gs.include('XMLHelper');


Really? Dude, that would be awesome, but I can't seem to get it working. This is my newly zbooted instance. I created the "testing6" application and this is my Scripts - Background:



xmlhelper.png





And this is the output:


xmlhelper2.png



Have you changed the "Accessible from" setting in the XMLHelper Script Include record. This is what it looks like out of the box:


xmlhelper3.png




If you have this working I would definitely buy you a beer... or two or three!