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
‎03-19-2021 01:08 PM
Someone with a similar issue: https://community.servicenow.com/community?id=community_question&sys_id=462854d2dbb0d340b61ff3231f96...
Does your runtime values give any clue to undefined string value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 09:56 AM
Sorry for the late reply. But no, the runtime values are completely blank.
I tried adjusting the input back to the payload and adjusting the script. I get different errors when testing so I just published it into the subflow I want and now I'm getting a whole new error.
Error: "console" is not defined.,Detail: "console" is not defined.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 01:56 PM
Ok so if there's an array in the payload you're going to need to call a forEach loop on it, you can't just dot-walk to fields in an Array.object, as there is possibly several objects in the array with that same field. If you send me a sample of what the payload looks like I could help you further
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 02:21 PM
Hey Chris, it can never be that simple lol. Thanks for your reply. Here is the snippet that is coming over as an array. I'm just trying to get the id, boardId, start and end date. If you need the entire payload, let me know.
Issue
Fields
"customfield_10010": [
{
"id": 1064,
"name": "Demo Sprint",
"state": "active",
"boardId": 201,
"goal": "This is a Demo",
"startDate": "2021-03-17T18:09:00.000Z",
"endDate": "2021-03-24T18:09:00.000Z"
}
],

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 02:39 PM
Ok so yeah like first thing you should try because it might be that simple.
- Remove the script step and just use json parse step
- then in your subflow add a "For each" flow logic
- now when it asks you for "items" drag your Array.object custom field data pill from your custom action into it.
- Then you can access the fields inside the "For each" block of subflow
if that doesn't work and we have to do script, let me know.