- 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 09:39 AM
I love the video and think it will help - but it moves too fast and I can't stop it. Do you know how I can do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 11:00 AM
It's still not working, I'm getting the error "Unable to create serializable iterator for items:" with the For Each loop.
I added a script step to my custom action that takes the JSON object output that is created in the previous step as input to the script step. The one difference is you have a string as input, this one is JSON.
This is what I ended up with after following your video:
And my Outputs are:
My test flow is:
and the error from the test flow:
I'm really at a loss on this, what am I missing?
- 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-30-2025 08:03 AM
Ankur - I can't tell you how much I appreciate your help. I'm still getting the "Unable to create serializable iterator for items" error. I've watched your video several times and tried some changes, but I must be missing something. Since I'm not allowed to record anything, I have to do this the hard way.
My script step:
and the output for the script step:
When I test the action alone, this is what I see:
For step 2 - which is the PowerShell step, this is the output. As you can see, it appears the Output is a string. Output is the input to the script step.
And for the script step:
I thought I followed your video exactly, do you have any idea what is wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 09:58 AM
Here, try this:
In your script step, change "var parsedData = jsonobj;" to "var parsedData - jsonobj.body;"
var jsonobj = JSON.parse(inputs.response_json_object);
var parsedData = jsonobj.body; // Add body to this line
outputs.response_json_array = parsedData;
Then update your output variables to remove the body and status strings, and add a single string variable called name like you had previously. Outputs should be:
- response_json_array (Array.Object)
- response_json_array_child0 (Object)
- name (String)
- response_json_array_child0 (Object)
You Action Outputs should match this as well.
Some explanation:
Your JSON output has two top level keys: Body and Status. You can't iterate through this as the Flow is expecting an array of objects, but this is not an array. However, Body's value is an array of objects, and each of these objects contains a key called "name" which has a string value. Since Body contains the data you are after, we can pass that as the output instead, hence jsonobj.body instead of jsonobj.
Try messing around with this in a background script a little. I often do this if I'm trying to wrap my head around the data structure of an object.
Hope this helps!