- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 02:44 PM
I have a business requirement to find all groups a specific user is a member of in Active Directory and write the groups to the work notes on a record. There isn't an OOB action to do this for a specific user so I created my own. The action is working, but I can't figure out how to extract the data so I can write it to the record in Flow Designer.
The action returns the groups in a JSON object, but when I try to use the "For Each" flow logic , it doesn't allow me to select the output from the previous step.
Here is my action's output:
This is the flow I'm using to test my action and output - as you can see, I can't select the Groups from the previous step.
This is what the "Groups" output looks like from the 2nd step:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 10:21 PM
I attached gif now here.
you are storing json string in the script step output, but it should be object
if the input to script step is json object then don't use JSON.stringify()
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-29-2025 08:43 AM
your action should store that JSON string as Array of object in output variable
Then you can use "For Each" to iterate that array of objects
check this link
Flow - Custom Action returns Array.object but For Each loop shows 0 of 0
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-29-2025 09:10 AM
Ugh, it still doesn't work. I'm getting the error "Unable to create serializable iterator for items" on the For Each step. My suspicion is the code in the Post Processing & Handling step needs to be modified to make it an array, I just don't know how to do that.
Also, it's possible I didn't create the output correctly - I've not used an array as output before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 09:10 AM
check below links
Script for JSON Parse Action in Flow Designer
JSON Parser step - Flow Designer
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-29-2025 09:32 AM
I have seen those posts - and many more and have tried several of the solutions without success.
My action looks like this:
The PowerShell step returns data in the responseBody that looks like this:
The Post Processing & Handling has script that manipulates the responseBody - I really don't understand what it is doing, I swiped it from an OOB Active Directory action that returns the same type of data. In the OOB action, the response output is defined as JSON, not Array.Object.
So, how do I change that to an Array.Object?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 09:31 AM
here is the working solution, please see and enhance for your case
I believe I have answered your question with working solution.
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