Illegal access to private script include JSONParser

Geeky
Kilo Guru

Hi,

I am getting error message

{"error":{"message":"Illegal access to private script include JSONParser in scope rhino.global being called from scope sn_customerservice","detail":"Illegal access to private script include JSONParser in scope rhino.global being called from scope sn_customerservice"},"status":"failure"}
I have a Scripted Rest API as below;
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {


	body = global.JSON.stringify(request.body.data);
	return new createCase().create(body);
	
})(request, response);

And in script include I have below code;

var createCase = Class.create();
createCase.prototype = {
    initialize: function() {
    },

	create: function(values) {
		
		gs.info('function called');
       var parser = new global.JSONParser();
	var parsed = parser.parse(values);
		
// 		var json = new global.JSON();
// var parsed = new JSON().decode(values.json_output.toString());
		
        var sd = parsed.short_description;

    }
       return sd;
    },
	
    type: 'createCase'
};
1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Also instead of using JSONParser, you can straightaway use JSON.parse(values) and JSON.stringify() methods which does the same job also which are JS methods so wont throw any error of this kind.

 

Hope this helps.

 

Regards

Omkar Mone

View solution in original post

7 REPLIES 7

Omkar Mone
Mega Sage

Hi 

Is this SI type Accesible from all the scopes? If yes then try with this - 

return new <scope_name>.createCase().create(body);

 

where scope name is like, if scope is Global you would call this SI like this -

 return new global.createCase().create(body);

 

Hope this helps.

 

Regards

Omkar Mone

Omkar Mone
Mega Sage

Also instead of using JSONParser, you can straightaway use JSON.parse(values) and JSON.stringify() methods which does the same job also which are JS methods so wont throw any error of this kind.

 

Hope this helps.

 

Regards

Omkar Mone

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

can you update code as below:

Is this script include accessible from all scope? if yes then use with the api name


create: function(values) {


	var parsed = JSON.parse(JSON.stringify(values));	
        var sd = parsed.short_description;		
        var sd = parsed.short_description;

       return sd;
    },

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Geeky
Kilo Guru

How can I handle any unexpected error that may come through my code?