In this Power Automate tutorial, We will learn about Power Automate Apply to Each Current Item and how to get the current item using the apply to each control action in Power Automate.
Moreover, we will also cover the below topics:
- Power Automate apply to each current item id
- Power Automate apply to each current item value
- Power Automate apply to each current item index
Also, Read: Create SharePoint Online List using Power Automate
Power Automate Apply to Each Current Item
The Power Automate apply to each action to loop through an array of items. For example, we can use the Apply to each action to filter records or a list of items from the Microsoft SharePoint Online list in Power Automate.
In the following, we will see how to get the current item using apply to each control action in Power Automate.
Power Automate apply to each current item
Let us see how to get the current item value in apply to each action in Power Automate.
- In this example, we will use the below SharePoint list, to filter and get the employee status value is active.
- Log into Power Automate, select the instant cloud flow -> select trigger as Manually trigger a flow -> enter the flow name -> click create option.
- select the +new step and add the Get items to trigger action from the action triggers.
- Configure the SharePoint site address and list name. In the Filter Query, add the below expression to filter the employee’s active status:
Status eq 'Active'
Now and apply to each action from action triggers to loop through the list items, select values from the dynamic content.
- Add a Compose action and pass the apply to each current item that is presented under the dynamic content values.
- Save and test the flow by selecting the run flow option. In the below screenshot, we can see that our flow ran successfully.
- Expand the apply to each action we can see it loops and filters the 6 list items from the SharePoint list for the employee active status.
- Now we can see the output for the current item object from the SharePoint list.
This is how to get the current item value in apply to each action in Power Automate.
Check out: How to Parse JSON Object to Array in Power Automate
Power Automate apply to each current item id
Here we will see how we can get the current item id in apply to each action using Power Automate.
In this example, we will see how we can display only the current item id from the apply-to-each control action object for the employee’s Inactive status.
- Select the instant cloud flow -> select trigger as Manually trigger a flow -> enter the flow name -> click create option.
- select the +new step and add the Get items to trigger action from the action triggers.
- Configure the SharePoint site address and list name. In the Filter Query, add the below expression to filter the employee’s Inactive status:
Status eq 'InActive'
- Now and apply to each action from action triggers to loop through the list items, select values from the dynamic content.
- Add a Compose action and pass the apply to each current item that is presented under the dynamic content values.
- Now add a compose action and under expression pass the below expression, to get only the current item id.
item()?['ID']
- Once the flow has been saved, select the Test -> Manually -> Run flow option. In the below screenshot, we can see that our flow has run successfully.
- To view the output, Simply Expand the Compose action in the flow and we can see apply it to each current item ID displayed as highlighted below:
This is how to get the current item ID using apply to each action in Power Automate.
Have a look: How to Check If a Date is Blank in Power Automate?
Power Automate apply to each current item Value
Let us see how we can get the current item value to apply to each control action using Power Automate.
- Select the instant cloud flow -> select trigger as Manually trigger a flow -> enter the flow name -> click create option.
- select the +new step and add the Get items to trigger action from the action triggers.
- Configure the SharePoint site address and list name. In the Filter Query, add the below expression to filter the employee’s Inactive status:
Status eq 'InActive'
- Now initialize an Array Variable with array type as shown below: we will use the initialized variables later in our flow.
- Now and apply to each action from action triggers to loop through the list items, select values from the dynamic content.
- Add a Compose action and pass the apply to each current item that is presented under the dynamic content values.
- Add a new step and choose Append to array action in the Name select the initialized Variable array (VarArray) and in the values action pass the below expression to get the current item value.
item()?['Int']
- Add a Compose action and pass the initialized variable array value as an input, to view the array value of the inactive employees.
- Once the flow has been saved, select the Test -> Manually -> Run flow option. In the below screenshot, we can see that our flow has run successfully.
- To view the output, Simply Expand the Compose action in the flow and we can see apply it to each current item value displayed as highlighted below:
This is how to get the current item value in apply to each action using Power Automate.
Check: Power Automate Condition if a String is Empty
Power Automate apply to each current item index
Let us see how to get an index for the apply to each control loop current item in Power Automate.
In Power Automate, iteration indexes work only in the do until loop, if we want to get an index value then we can change the apply to each loop to do until loop.
But there is another way to get the index of apply to each loop by creating a variable and incrementing within the loop.
To achieve this follow the below steps:
- Select the instant cloud flow -> select trigger as Manually trigger a flow -> enter the flow name -> click create option.
- select the +new step and add the Get items to trigger action from the action triggers.
- Configure the SharePoint site address and list name. In the Filter Query, add the below expression to filter the employee’s active status:
- Now initialize an integer Variable and pass the value as 0 like below:
- Now and apply to each action to loop through the list items, select values from the dynamic content.
- Add a Compose action and pass the apply to each current item that is presented under the dynamic content values.
- Add a new step, select the increment variable, and choose the previously initialized variable under the name, and in the value field pass the value as 1 to increment by 1 for each loop.
- Add a Compose action and pass the initialized variable as an input, to view the current item index value. Save and Test the flow.
- Once the flow ran successfully, for the first apply to each current item it displays the index value as 1.
- In the same way, for the third apply to each current item it displays the index value as 3.
This is how to get an index for the apply to each control loop current item in Power Automate.
In this Power Automate tutorial, We have learned about Power Automate Apply to Each Current Item and how to get the current item using the apply to each action in Power Automate
Moreover, we also covered the below topics:
- Power Automate apply to each current item id
- Power Automate apply to each current item value
- Power Automate apply to each current item index
Furthermore, you may like some more Power Automate tutorials:
- Power Automate Condition If Blank
- Conditionally Update SharePoint list items using Power Automate
- Power Automate Dataverse Upload a File or an Image
- Remove Duplicate items from SharePoint List using Power Automate
- Create a Site column in SharePoint Online using Power Automate
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.