Using JSON Parser on Array.Object in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2021 08:09 AM
Hello,
I recently created an Action in Flow Designer that uses JSON Parser to get some custom field variables on a JSON. This worked great and I was able to get my output variables. However, there were a few more custom fields that I needed to have an output variable for and it's not letting me since its in an Array.Object.
I'm not good at scripting but I created a Script Step to get these fields but its not working.
I've tried making the input variable the payload and going straight to the array.object data pill. When making the input the array.object data pill, it gives me an "Error: u,Detail: Unexpected token: u" when doing the test. When making the input the root payload from the JSON Parser step, it gives me an "Error: o,Detail: Unexpected token: o".
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2022 05:59 AM
Hi Sivaranjani,
(function execute(inputs, outputs) {
if (inputs.step_input_status_code == '200') {
var responseObj = JSON.parse(inputs.step_input_response_body);
outputs.step_output_statusid = responseObj.value.user_lo_status_id;
outputs.step_output_createddt = responseObj.value.user_lo_create_dt;
outputs.step_output_lastused = responseObj.value._last_touched_dt_utc;
}
})(inputs, outputs);
Below is the output variables am trying to populate based on the response body.
Please find the response body- From the below output i need to get the "user_lo_status_id" as output. When i am trying to parse the output its showing empty. Could you please check once.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2022 02:14 AM
Try
var responseObj_string = JSON.stringify(inputs.step_input_response_body);
var responseObj = JSON.parse(responseObj_string);
outputs.step_output_statusid = responseObj.value.user_lo_status_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 12:30 AM
Hi,
Please let me know if you were able to get this working.
Thanks,
Sivaranjani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 02:28 AM
Shouldn't be posting a new question to a thread that's a year old.
The original question is with Paris version and I thought there was a bug with array objects that is now fixed in the newer version.
That is, the content of the original question and replies probably are different because I have it working in my San Diego instance. Nevertheless, I won't reply in this thread because it'll mix the contents with different ServiceNow versions and make it more difficult for others.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 05:56 AM
I have missed the JSON PATH with is value[0] instead i have used only value. This has caused me the error. Thanks for your help