Flow Designer: How to Loop through a Comma-Separated String

jmiskey
Kilo Sage

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

 

 

1 ACCEPTED SOLUTION
10 REPLIES 10

Sandeep Rajput
Tera Patron

@jmiskey You can apply a string split() transform function on your flow variable. For more information please refer to https://docs.servicenow.com/bundle/xanadu-build-workflows/page/administer/flow-designer/reference/st....

 

Hope this helps.