How to Check if an Item Exists in a SharePoint List with Power Automate

Do you need to check if an item already exists in your SharePoint list?

When it comes to managing your data, making sure that a particular row doesn’t already exist can be a crucial step. Otherwise, you will end up with duplicate data.

To check if an item already exists in your list, you can query the list for that item. If the results are empty, this means the item does not exist.

This article will walk you through the method of checking if an item exists in a SharePoint list.

Checking If Item Exists with Get Items Action and Filter Query

When working with SharePoint lists there may be instances where you need to check if an item exists.

One approach to achieve this is by using the Get items action combined with a filter query. This section will guide you through the steps on how to accomplish this task.

Get Items Action

The Get items action in Power Automate allows you to retrieve items from a SharePoint list. Here are the steps to follow to use this action.

  1. Add the Get items action from the SharePoint connector to your flow.
  2. Select the appropriate SharePoint site from the Site Address dropdown list.
  3. Select the list from the given options in the List Name dropdown.
  4. Click on the Show advanced options link at the bottom of the action. This will reveal the filter query option in the action.

Now you will be able to apply a filter to check for a specific value in your list.

Filter Query

The filter query is an essential component for identifying if an item exists in the SharePoint list.

Instead of retrieving all items, you can apply a filter query to get the specific item you’re looking for.

LastName eq '@{outputs('Compose')}'
  1. Add your required filter to the Filter Query field in the Get items action.

For example, you can use the above filter query to check if a value exists in a field named LastName. This will find all items in the list where the LastName column has a value equal to the value from a Compose action given by the dynamic content @{outputs('Compose')}.

The Get items action will return the list of items that match the criteria. If the action retrieves any items, it means the item exists. Otherwise, the item does not exist in the SharePoint list.

To confirm the existence of the item, you can use a Condition action to evaluate the length of the items returned.

Condition Action to Check Get Items Output

To check if an item exists in a SharePoint list with Power Automate, you will need to use a Condition action after the Get Items action.

Here’s how to use the Condition action to check the results of your Get items action.

  1. Add the Condition action to your flow after the Get items action.
  2. Add the expression length(outputs('Get_items')?['body/value']) to the left side of the condition. This will return the count of items from the array returned by the Get items action.
  3. Select the greater than or equal to option as the condition.
  4. Enter 1 to the right side of the condition.

This condition will check if the number of items returned by the Get items action is 1 or greater. This is equivalent to the item existing or not.

  1. If yes: You can add all the actions in the If yes branch that you want to run if your item already exists in the SharePoint list. For example, you might want to update the list item.
  2. If no: You can add all the actions in the If no branch that you want to run if your item does not exist in the SharePoint list. For example, you might want to add a new list item.

This allows you to check for any value in your list and then

Conclusions

It’s possible to check if an item exists in a SharePoint list during your flow.

You can use the Get items action with a filter query to retrieve specific data from your SharePoint list. If the query returns any data, then the item exists. Otherwise, the item does not exist.

This can be checked with a Conditon action by using the length function to check the number of items returned.

Have you needed to check if an item already exists in your lists? How did you do this? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!