Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

"apply to each" within another "apply to each"

(0) ShareShare
ReportReport
Posted on by 54

Hi,

 

I've been experimenting Microsoft flow to initiate an approval request on a sharepoint list submission.

Have encountered many challenges, redesigned the flow and feel i'm the right direction until i hit a barrier which had put me on a hold. I've looked at many discussions thread around here however none was able to help.

 

Below is the process of my flow that I have summarize to the challenge faced.

 

I have an array of items.

[
  "DepartmentA->DeptAOwnerEmail",

  "DepartmentB->DeptBOwnerEmail",

  "DepartmentC->DeptCOwnerEmail",

  "DepartmentD->DeptDOwnerEmail"
]

 

1. used "Apply to each" & item() to extract data from array: GOOD

"DepartmentA->DeptAOwnerEmail"

 

2. using split command, i extracted data into another array(just 2 items per array): GOOD

 

Example:

[
  "DepartmentA",

 

  "DeptAOwnerEmail"
]

 

3. Now the challenge I have is using the Array(output) and passing it on to another "Apply to each" loop

 

The reason I'm doing this is because I am trying to set an initialized variable with the output from here which will be used in a later part of the flow.

 

dept = "DepartmentA"

deptowner = ""DeptAOwnerEmail"

 

in theory, if initial array consists of 4 items, there will be 4 sets of dept & deptowner.

within the loop itself, an approval request will be made using data from above. Initial array value depends on the data on the sharepoint list itself, ranges from 0 to 11 maximum.

 

Without even reaching "set variable" action, I can see that the output from previous "split" command is NOT being passed on to the 2nd "Apply to each" loop.

 

Any help would be much appreciated.

 

 

  • Verified answer
    asri_zainal Profile Picture
    54 on at
    Re: "apply to each" within another "apply to each"

    my brain was exploring again and it seems that I can get rid of the 2nd "apply to each loop" and use filter array to get single items from the previous arrays.

    using the test flow seems to show positive results, will try to implement back to my original flow.

  • asri_zainal Profile Picture
    54 on at
    Re: "apply to each" within another "apply to each"

    - same results even without the scope in fact i only added the scope later on so that easily hide certain part of the flow trying to figure out what was wrong

    - Output of compose 2 is not blank

     

    just to be sure i'm not crazy or anything, i created a new test flow with the most basic information to prove that "apply to each" loop in another "apply to each" doesn't pass output from the first loop to the other. I try to keep it as close to my current flow by using same format of array and commands.

     

    It could just be a limitation however I was not able to find any resources to explain this. if i've hit a dead end here then I'll need to redesign the flow again.

     

    screencapture-asia-flow-microsoft-manage-environments-Default-61569b2e-8e58-4771-9656-aaca286ff449-flows-5a226cf3-bdfd-43cf-9638-0a58d0f80b51-1508848835154.png

    screencapture-asia-flow-microsoft-manage-environments-Default-61569b2e-8e58-4771-9656-aaca286ff449-flows-5a226cf3-bdfd-43cf-9638-0a58d0f80b51-runs-08586927582510165168972505330-1508849199854.png

     

    Basically my requirement is:

    - Sharepoint list consists of request form with single user data.

    - data includes 14 Yes/No checkboxes for departments that user need access to

    - the flow will collect all the "Yes" data and append into an array into the format: Dept->DeptOwner@company.com

    - Apply to each loop for each array items using item() follwed by split() from previous compose out "->" to gather generate a 2nd set of array which will only consist of 2 items: Dept & DeptOwner@company.com

    - Now the plan is to insert a 2nd "apply to each" loop to assign 2 variables from above: dept=Dept & DeptOwner@company.com

    - Once the variables are set, an approval proccess will be initiated using the 2 information above.

  • v-micsh-msft Profile Picture
    on at
    Re: "apply to each" within another "apply to each"

    Hi @asri_zainal,

     

    Take a try to remove the scope Action, just use the Compose, then after Compose 2, add the Apply to each 2 drectly to check.

    Further, would you please take a check with the Output of Compose 2, to see if it created the corresponding items?

     

    Besides, if you could share more details about your goal and the SharePoint list data, maybe I could offer a better solution.

     

    Regards,

    Michael

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492