- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 03:17 AM
Hi
I try to get my JSON array output to work in the flow designer for each step.
But it just count 0 of 0
The output is from a Powershell script and run thru the JSON parser in the action step
The JSON Object array output:
{ "root": { "root_array": [ { "ID": "1", "IDA": { "CollectionID": "SMS00001", "CollectionMemberCount": "270", "CollectionName": "All Systems", "CollectionType": "2" }, { "ID": "12", "IDA": { "CollectionID": "CHQ00016", "CollectionMemberCount": "1", "CollectionName": "TestU", "CollectionType": "1" } }
}
}
}
How can i make the for each item loop to work?
( I'm new to ServiceNow so bare with me 🙂 )
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 08:32 AM
If you click on your action in the flow execution details. Does it return the correct values like this under "runtime values"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 03:22 AM
Hi Melker,
Just a quick question. The output in your example is missing a ] to close the array. Is that typo on your community post or perhaps the issue that breaks your code.
//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 03:30 AM
To add, there where some other inconsistence as well. I think your JSON should look like this:
{
"root":
{
"root_array": [
{
"ID": "1",
"IDA": {
"CollectionID": "SMS00001",
"CollectionMemberCount": "270",
"CollectionName": "All Systems",
"CollectionType": "2"
}},
{
"ID": "12",
"IDA": {
"CollectionID": "CHQ00016",
"CollectionMemberCount": "1",
"CollectionName": "TestU",
"CollectionType": "1"
}
}
]
}
}
if I build what I think you are looking for, my action output would look like this:
and then in the flow, I would use the root_array in the forEach like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 04:13 AM
This is my output from the Json parser step standalone action and in the flow:
{
"root": {
"root_array": [
{
"ID": "1",
"IDA": {
"CollectionID": "SMS00001",
"CollectionMemberCount": "270",
"CollectionName": "All Systems",
"CollectionType": "2"
}
},
{
"ID": "11",
"IDA": {
"CollectionID": "CHQ00015",
"CollectionMemberCount": "2",
"CollectionName": "Test",
"CollectionType": "2"
}
},
{
"ID": "10",
"IDA": {
"CollectionID": "CHQ00014",
"CollectionMemberCount": "0",
"CollectionName": "OSD - Deploy Master Windows 8 Image",
"CollectionType": "2"
}
}
]
}
}
and the input look lite this in for each
Where have I done made a mistake?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 05:09 AM
Seems to be in the output of the step I have the issue.
Looking at Episode 25 - Complex Objects in ServiceNow Flow Designer
but don't get to to be correct