- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:34 AM
I have a Flow that has a Flow Variable whose value is being dynamically built. Basically, it is building a list of AD Groups to add someone to, based on the answers to a bunch of questions in the Catalog Item. So when it is complete, it is a String that is structured like this:
AD_Group_1,AD_Group_2,AD_Group_3
I now would like to run a "For Each" action on it, to loop through each of those 3 values. However, a "For Each" does not want to run against a "String" variable, and you cannot create Flow Variables with an "Array" type.
So, unless I am missing something, I assume that I somehow need to convert my String into an Array (maybe via a Custom Action)? What is the easiest way of doing that? Has anyone come up with the code for that already? Or is there a different way I can loop through those values in my comma-separated string in Flow Designer?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:42 AM
Take a look at this post, it should help you solve your issue.
Action Designer - Custom action to convert comma separated strings into array

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:42 AM
Take a look at this post, it should help you solve your issue.
Action Designer - Custom action to convert comma separated strings into array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 12:05 PM
That looks promising, but the only issue is that it shows the output as a "String" variable. I tested it out, and the "For Each" action in ServiceNow does not allow you to use a String variable on it. I tried changing it to "Array.String" output type, but is not working either.
Any idea on what I need to tweak to get this to work in a "For Each" action?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 12:09 PM
Can you share the way you have your action configured? You can use Array.string as an output, and use for each on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 12:24 PM
I had to update the Output types to "Array.String" in BOTH the Script section AND the Output section. When I did that, it all worked out.
Thanks!