JSON Undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2016 11:20 PM
Hi All,
I am working in a scoped application and getting this error log while trying to execute the JSON code, can anyone help me to fix this
java.lang.SecurityException: JSON undefined, maybe missing global qualifier
Caused by error in sys_trigger.9ef828964f5f9a00cbfa7bb28110c798 at line -1
Regards,
DInesh N
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2016 11:55 PM
Hi Dinesh,
This error is due to undefined json string.
to avoid the exception you can use below check in your code :
if(json _ String!==undefined) {
//parse json here
}
Thanks,
Param

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2016 12:00 AM
Hello Dinesh,
You may want to take a look at :
JSON.stringify() - JavaScript | MDN
After stringify the text, JSON parsing should not throw errors.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2016 01:04 AM
Servicenow server side is using ES3, so somethings don't exist natively. JSON is one of them. So to include it now that scoping has been introduced.
E.g.
//Say event.parm1 is the stringified/encoded JSON payload;
gs.log('sys_trigger_9ef828964f5f9a00cbfa7bb28110c798 (string): ' + event.parm1);
var parser = new JSONParser();
var obj = parser.parse(event.parm1);
gs.log('sys_trigger_9ef828964f5f9a00cbfa7bb28110c798 (obj.property): ' + obj.somePropertNameGoesHere);