In this article, we are going to learn about apply to each control action. Apply to each is used to iterate all the items in a collection. It can be an array, list, or anything which has more than one item inside it.
If you know some other programming languages then apply to each control action is similar to for loop.
Creating the Apply to Each control action flow in power automate
Let's create an array in power automate and add apply each control action to traverse the array. Also, store the list of items from an array to a SharePoint list.
Go to your SharePoint site. Create a Blank list.
Name the list as Subjects and click on Create.
We have our SharePoint list of Subjects created.
Now, go back to power automate and create a manually triggered flow. Click on the New step.
Select Initialize variable (Variable) from actions.
Initialize a variable as type Array. Enter the value for the array. Click on the New step.
Select Apply to each (Control) from Actions.
Add the MyArray variable from dynamic contents. Click on Add an action.
Select Create item (SharePoint) from actions. Add the site address and select the list. Select the Current item which takes one single value from the array.
Save,Test, and Run Flow. It might take few more seconds to run because the control traverses the whole array.
After running get back to the SharePoint list. You can see that control has created a record for each item from an array to the list.