How to loop through SharePoint list items in Power Automate

In this Power Automate tutorial, we will see how to loop through list items in SharePoint using Power Automate. I will show you 2 examples here, in one example, we will loop through all items, and in the other example, we will loop through SharePoint Online list items based on a filter condition.

To loop through SharePoint Online list items in Power Automate, we can use the Get items flow action.

Scenario

We will create a SharePoint list called the Product Inventory Status list, where we will track the product sales quantity status. The list contains the below columns:

  • Product name(Title)
  • Total Quantity
  • Sold Amount
  • Status

Based on the number of products, we will update the status of the item as In stock, low stock, and Out of stock. Also, we will send an email to the Sales department if the status is low stock, and out of stock.

For example from this list, we will take the product ‘ z-Mouse’, the sales quantity this week is 0, status =Out of stock.

After that, the quantity is added to 150, status = In stock. Once the quantity decreased to 50, or it is less than 100 and greater than 1, then status = Low stock.

Similarly, we will loop through all items and check the quantity and update the status, you can do it on a daily basis, weekly basis and some days in a week based on the requirement.

Implementation

  • For this, we will create a Schedule cloud flow, which will trigger on Monday every week.
  • Using the get items action, we will get all the items.
  • Then we will loop through all items in the SharePoint list. And check the item quantity.
  • If the Total quantity >= 100, then update the status of that product as ‘In stock’. Else if the Total quantity is <100 AND the Total quantity is> 1, then the status of that product is ‘Low stock. Otherwise status = Out of Stock.
  • Based on this condition we will send an email via Outlook to the Sales Department.

Loop through All SharePoint list items using Power Automate

Here we will see how to loop through SharePoint list items using Power Automate.

Before we will start creating a power automate flow, we need to set up our SharePoint list.

As I have already created the SharePoint list called Product Inventory Status, which contains the below columns:

Column nameData type
Product name(Title)Single line of text
Total QuantityNumber
Sold AmountCurrency
StatusChoice

Here, I have also added a few items to it. And this is how the list looks like.

Using microsoft flow loop through SharePoint list

Now let’s create the flow in Power Automate, that will loop through SharePoint list items

Step 1: Log in to Power Automate, click on +Create -> select the Scheduled Cloud Flow.

How to loop through SharePoint list automatically with power automate
How to loop through SharePoint list automatically with power automate

Then provide the flow name and select Starting date and Time, then repeat every week, and select Mondays(M). Click on Create.

Power automate loop through SharePoint lists

Now you can see scheduled cloud flow trigger is added to the flow.

Microsoft Power automate loop through SharePoint lists item

Step 2: Next click on +New steps -> select Get items action -> then provide the below information.

  • Site address: Select or provide the SharePoint Site address
  • List name: Select the list name from the dropdown.
Microsoft Power automate loop through SharePoint lists

Step 3: Now we will check the Total quantity by looping through each item in the SharePoint list.

So, click on +New step -> select Condition action, then provide the below information:

  • Choose a value: Select the Total quantity from the dynamic content. This will add Apply to each action.
  • Operator: Select the operator as ‘is greater than or equal to‘ from the options.
  • Choose a value: Write the value as 100.
How to loop through SharePoint lists using Microsoft Power automate

If the above condition is true, then in If Yes part, click on Add an action -> select Update item action.

Then provide the below information:

  • Site address: Select or provide the SharePoint site address
  • List name: Select the List name from the dropdown
  • Id : select Id from the dynamic content.
  • Title: Select Title from the dynamic content
  • Status: Select the status as ‘In stock ‘ from the drop-down.
Loop through SharePoint lists using Microsoft Power automate
Loop through SharePoint lists using Microsoft Power automate

In the If No part of the condition, click on Add an action -> select Condition action. Then provide the below information:

  • Choose a value: Select the Total quantity from the dynamic content. This will add Apply to each action.
  • Operator: Select the operator as ‘is less than’ from the options.
  • Choose a value: Write the value as 100.

After that click on +Add , to add another condition. So select Add row options -> then select AND, and provide the below information:

  • Choose a value: Select the Total quantity from the dynamic content. This will add Apply to each action.
  • Operator: Select the operator as ‘is greater than’ from the options.
  • Choose a value: Write the value as 1.
Loop through SharePoint lists using Ms flow
Loop through SharePoint lists using Ms flow

If the above condition is true, then in If Yes part, click on Add an action -> select Update item action.

Then provide the below information:

  • Site address: Select or provide the SharePoint site address
  • List name: Select the List name from the dropdown
  • Id : select Id from the dynamic content.
  • Title: Select Title from the dynamic content
  • Status: Select the status as ‘Low stock ‘ from the drop-down.

After that, we will send an email to the Sales department. So click on Add an action -> select Send an Email (V2) action. Provide the below information:

  • To: Provide the recipient’s email, to whom you want to send an email.
  • Subject: Provide the subject of the email
  • Body: Provide the body of the email
How to loop through SharePoint lists using Ms flow

If the above condition is false, then in If No part, click on Add an action -> select Update item action.

Then provide the below information:

  • Site address: Select or provide the SharePoint site address
  • List name: Select the List name from the dropdown
  • Id : Select Id from the dynamic content.
  • Title: Select Title from the dynamic content
  • Status: Select the status as ‘Out of stock ‘ from the drop-down.

After that, we will send an email to the Sales department. So click on Add an action -> select Send an Email (V2) action. Provide the below information:

  • To: Provide the recipient’s email, to whom you want to send an email.
  • Subject: Provide the subject of the email
  • Body: Provide the body of the email
How to loop through SharePoint lists using Microsoft flow

Now our flow is ready, so we can test the flow manually.

Step 4: To run the flow click on the Test icon -> select manually -> click on the Test button -> click on Run flow(after configuring the connection) -> click on Done.

You can see your flow ran successfully in Power Automate.

Using Power Automate flow loop through SharePoint list

Now you can see the status get updated in the SharePoint list automatically.

How to loop through SharePoint list automatically with power automet

This is an example of how to loop through a SharePoint list using Power Automate.

Power Automate Loop through SharePoint List items Based on Filter Condition

In this Power Automate tutorial, we will see how to loop through the SharePoint list items using Microsoft Flow or Power Automate based on a filter condition.

Scenario:

Consider a company that organizes various events such as webinars, workshops, and conferences. However, the person in charge of organizing these events frequently overlooks them.

As a result, they need to automatically notify the organizer on the day of the event as well as one day before the event. They won’t miss any events.

Implementation

We’ll create a SharePoint Event list with information about all of the events, including their dates.

The flow will check the SharePoint list every day and filter out events that are occurring today or tomorrow.

Following that, the flow will run through the filtered list of events and send an email to the organizer for each event taking place today and tomorrow.

By applying this Microsoft power automate, the organizer will receive timely information about the event, ensuring that they are kept informed and can efficiently manage their schedule.

Before we start creating the flow, we need to set up our SharePoint Event list. As I have already created the Event list in SharePoint, it looks like below. The list contains the below columns:

Column NameData type
TitleSingle line of text
OrganizerPerson
Event date and timeDate and Time
LocationLocation
AttendeesPerson
DescriptionMultiple line of text
Event typeChoice
Event statusChoice
Event list in SharePoint
power automate loop through sharepoint list items
power automate loop through sharepoint list items

Let’s create a flow that will loop through sharepoint list items based on a filter condition using power automate.

Step 1: Log in to Power Automate, and then click on +Create icon on Left Navigation. Select Schedule cloud flow.

MS flow loop through SharePoint list items
MS flow loop through SharePoint list items

Then provide the Flow name and select Starting date and time, and select Repeat 1 Day. Then click on Create.

Using power automate loop through sharepoint list items
Using power automate loop through sharepoint list items

Now you can see the Scheduled cloud flow trigger action is added to the flow.

Using Microsoft power automate loop through sharepoint list items
Using Microsoft power automate loop through sharepoint list items

Step 2: Next we will get items from the SharePoint list, those event date is greater than or equal to today’s date. So, click on the +New step and select the ‘Get items‘ action. Then provide the below information

  • Site address: Select or provide the site address
  • List name: Select or provide the list name
  • Filter query: provide the below query
(EventDateandTime ge '@{formatDateTime(utcNow(),'yyyy-MM-dd')}')
  • Top count: Set the Top count as 100
Using Microsoft flow loop through sharepoint list items
Using Microsoft flow loop through sharepoint list items

Step 3: Next we will check the Event date is Today or tomorrow based on that we will notify the organiser through email.

So. click on the +New step ->select Compose action. Then provide the below information:

  • Input: Select the Event date and time from the dynamic content. This will automatically add Apply to each action, which will loop through each item and store the date in the compose.
Using MS flow loop through SharePoint list items
Using MS flow loop through SharePoint list items

Step 4: To check the date, click on Add an action-> select Condition control action. Then provide the below information:

  • Choose a value: Here provide the below expression:
formatDateTime(outputs('Compose'),'yyyy-MM-dd')
  • Operator: Choose operator as is equal to
  • Choose a value: Here provide the below expression:
formatDateTime(utcNow(),'yyyy-MM-dd')

If the above condition is true then we will send an email, else we will check the date is equals to tomorrow’s date and based on that we will send an email to notify.

In the If yes part of the condition, click on Add an action, then select ‘Send an email (V2)‘ action. Then provide the below information:

  • To: Provide the Organiser email from the dynamic content
  • Subject: Provide the subject like below screenshot
  • Body: Provide the body like below screenshot
Microsoft Power automate loop through SharePoint list items

Then in the if No part of the condition, click on Add an action -> select Condition action. Then provide the below information:

  • Choose a value: Here provide the below expression
formatDateTime(outputs('Compose'),'yyyy-MM-dd')
  • Operator: Choose the operator as “is equal to”
  • Choose a value: Here provide the below expression
formatDateTime(addDays(utcNow(),+1),'yyyy-MM-dd')

Then in the If yes part, click on Add an action -> select ‘Send an email(V2)‘ action. Then provide the below information:

  • To: Provide the Organiser email from the dynamic content
  • Subject: Provide the subject like below screenshot
  • Body: Provide the body like below screenshot
MS Power automate loop through SharePoint list items

Now our flow is ready, we can test our flow.

Step 5: To test the flow, click on the Test icon -> select Manually -> select Test button. Then configure the action with connectors -> click on Run flow -> click on Done. You can see flow ran successfully.

How to loop through SharePoint list items using MS Power automate
How to loop through SharePoint list items using MS Power automate

The next organizer will get an email via Outlook, just to remind you.

How to loop through SharePoint list items using  Power automate
How to loop through SharePoint list items using Power automate

This is how to loop through SharePoint list items based on a filter condition using Power Automate.

Conclusion

Looping through all SharePoint Online list items in Power Automate is easy and we can do it using the Get items flow action. I have explained here, how to loop through SharePoint list items using Power Automate.

You may also like the following Power Automate tutorials:

>