- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2015 11:49 AM
I'm having a problem with parsing the result of a web service. the variable "result" is defined earlier in the code. If i remove the two lines about parsing then everything works, except I can't get the data I need out of the response. Here is my code:
try {
var r = new sn_ws.RESTMessageV2('ittools', 'get');
r.setStringParameter('group_name', result);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
gs.addInfoMessage("Finished REST Message" + response);
var parser = new JSONParser();
var parsed = parser.jsonParse(response);
//gs.addInfoMessage("Finished Parsing" + parsed.Owners[0].UserNames.UTTyler);
And here is the error that I get:
Caught exception in InterpretedScript <refname>: org.mozilla.javascript.InterpretedScriptException: Caught exception in InterpretedScript <refname>: org.mozilla.javascript.InterpretedScriptException: Caught exception in InterpretedScript <refname>: org.mozilla.javascript.JavaScriptException: org.mozilla.javascript.WrappedException: WrappedException of The undefined value has no properties.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2015 06:41 AM
I had a two different ways that worked. However, it also greatly depends on how the response if formatted as to which way works. At first our response had characters in it that the ServiceNow parser didn't like but would work on any other standard JSON parser you try on the web. Due to those characters I had to decode it first then parse it. I would love to know if one of these ways helped you.
Here the first that worked for me:
var parser = new global.JSON();
var parsed = parser.decode(responseBody);
var mydata = JSON.parse(parsed);
After a change to how the object was sent back to me I was able to use a single line:
var mydata = JSON.parse(responseBody);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2015 08:59 PM
Hi David,
You may find the below thread helpful.
https://community.servicenow.com/message/789647#789647
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2015 06:58 AM
I believe they changed the OOB setting of this for Fuji. I found the script you are talking about but it is already set to "All application scopes"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 08:41 PM
Hi David,
Any further luck with this? We have also just upgraded to the Fuji release and having the same issue with one of our workflows.
Thanks,
Skye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2015 06:41 AM
I had a two different ways that worked. However, it also greatly depends on how the response if formatted as to which way works. At first our response had characters in it that the ServiceNow parser didn't like but would work on any other standard JSON parser you try on the web. Due to those characters I had to decode it first then parse it. I would love to know if one of these ways helped you.
Here the first that worked for me:
var parser = new global.JSON();
var parsed = parser.decode(responseBody);
var mydata = JSON.parse(parsed);
After a change to how the object was sent back to me I was able to use a single line:
var mydata = JSON.parse(responseBody);