- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 04:47 AM
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"}
(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'
};
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 04:55 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 04:50 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 04:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2020 06:10 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2020 03:54 AM
How can I handle any unexpected error that may come through my code?