- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 02:54 AM - edited ‎05-19-2025 02:56 AM
My action makes an API call and this API returns the below response body
{
"requestDetails": {
"comments": "mycomments",
"requestParams": [
{
"requestkey": "342",
"Start Date": "2025-05-15 12:44:25",
"Request Type": "AddRequest",
"value": "asasasasa01G3PCBKB170TEP3CC2BBH",
"status": "Request Created"
}
],
"Tasks": [
{
"Task ID": 999,
"State": "New",
"comments": " test comments"
},
{
"Task ID": 29,
"State": "Error",
"comments": " test 123comments"
} // these tasks could be multiple each with a diff ID and State
],
},
"msg": "SUCCESS",
"errorCode": "0"
}
The "Tasks" can be multiple or single. It depends on the API.
The action returns couple of values back to the subflow - errorCode, entire 'Tasks' object.
When errorCode is 0, I want to loop through the Tasks object in my subflow to do the following. The conditional check for validating errorCode is already in place. not getting how to iterate through the object in subflow to achieve -
1. create a new sc task when task id with state = Error.
1. update main ritm to complete when all task id with state = Completed.
How to loop through object in sub flow ? I am using flow designer
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 04:54 AM
Hi,
If you define the output from the action as an object containing an array you should be able to loop through the array, just as you would when performing a lookup of records.
See attached image.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 10:49 PM
If you don't know which one of them contains data, you'll need to loop through all three arrays.
Or, if possible, have the output of the action concatinate all the data into one big array, and loop through that instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 05:33 AM
I already shared the videos and it will help you to use Integration Hub parser step
Did you check that?
Also what's your flow action returning?
If it's returning an object, did you try to use For Each to iterate
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:44 PM - edited ‎05-19-2025 06:49 PM
The object is as below
{
"New": [],
"Open": [],
"Closed": []
}
Each element may or may not have array elements. Example : New may have 3 values and Closed may be empty and Open may have 1 array value
I want to find which one has values and loop through them dynamically in my subflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 04:54 AM
Hi,
If you define the output from the action as an object containing an array you should be able to loop through the array, just as you would when performing a lookup of records.
See attached image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:50 PM
The object is as below
{
"New": [],
"Open": [],
"Closed": []
}
Each element may or may not have array elements. Example : New may have 3 values and Closed may be empty and Open may have 1 array value
I want to find which one (New/Open/Closed) has values and loop through them in my subflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 10:49 PM
If you don't know which one of them contains data, you'll need to loop through all three arrays.
Or, if possible, have the output of the action concatinate all the data into one big array, and loop through that instead.