For Each Flow activity question

EricG2
Tera Expert

I have a question on Flow For Each activity.

 

I have a use case where I'm ordering user access to specific Cloud applications or software installations.

So far, each cat_item has only required that a user be added to a single AD Security group

 

Using the AD Integration Hub spoke, we've been very successful in adding users to the security groups up to now.  Part of the Flow uses a Decision table (referencing the cat_item) to pull what AD Group is required. 

 

Now I've just received a request where access an application requires 2 security groups.

Well that is not were the issue lies.  By using a For Each activity, i am successful getting the user into each group for 2 or more returned records.  But when the application only has one record, the Add to AD Group activity does run.

EricG2_2-1754660802042.png

I retested this by adding a second group, and it worked.

 

Any suggestion on how to account for records that only have 1 returned decision vs multiple?

 

Here are my flow activities:

EricG2_3-1754660941074.png

EricG2_4-1754661014912.png

EricG2_5-1754661059317.png

EricG2_6-1754661140594.png

Please let me know if i forgot to include something.

 



 

2 REPLIES 2

pavani_paluri
Giga Guru
Giga Guru

Hi @EricG2 ,

 

You need to force the result into a list/array every time, even if it’s just one record.
Use “Get Records” before the loop. Instead of directly looping over the Decision Table output:
Capture the AD group name(s) from the decision table. Use Get Records action (filter by those names) to retrieve them as a record list. Feed that list into the For Each.

 

Wrap single value in a list
If you’re working with a Data Pill from the decision table:

Create a List Collector-style Data Pill variable or script step.

In a small inline script step before the loop and pass it to your ForEach.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

@pavani_paluri  I'm assuming that this would be a Custom Activity and not something OOB.