cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Query a SharePoint List to see if item exists

Hi All,

I'm working on a flow to create an item in a SharePoint list if it doesn't exist. I used 'Get items' from list B, but when i get to the condition i'm not sure what to use. Condition I need is if item exists (using title) then update item, if not create a new item.

 

Any ideas? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Query a SharePoint List to see if item exists

Hi @_sourcecod3_ ,

 

Could you share all the screenshots of the Flow configuration?

In the screenshot I provided, If yes represents that the item does not exist, and if no represents updating the existing item.

Moreover, the Condition is used to judge whether the item exists or not, and is not used in Apply to each.

If the item does not exist, do not use the Dynamic content contained in Get items when configuring Create item action.

26.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Query a SharePoint List to see if item exists

@_sourcecod3_ 

You are much better off using an OData filter with the GetItems action rather than a condition.  Here is a link to info on using OData filters. 

 

What you can do is use GetItems with an OData filter that will only return items where your title matches the search term that you are looking for.  If it returns anything other than zero items, then you'll want to create a new list item.  You can use the length expression to check how many items were returned, if any.

 

Please let me know if, after reading the link I provided, you need an example.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Helper III
Helper III

Re: Query a SharePoint List to see if item exists

@ScottShearer, thanks for the response and the link. I'm just a bit confused, if i do the ODATA filter on the title field of 'List B', like this Title eq 'Title', how can I use this to find if that title exists in list B? Wouldn't i still have to use a condition for that? If so, how could I go about doing that? 

 

Thanks again.

Highlighted
Community Support
Community Support

Re: Query a SharePoint List to see if item exists

Hi @_sourcecod3_ ,

 

Please try using this structure:

10.PNG

Expression reference:

length(body('Get_items')?['value'])

Please let us know if you have any questions.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper III
Helper III

Re: Query a SharePoint List to see if item exists

@v-bacao-msft Thanks for the example, this works when the item exists in list B, but if it doesn't the flow stops at the condition. conditionStopped.PNG

 

Any ideas as to what to change the condition to so that if the item doesn't exist in list B it will continue with the flow? 

 

Thanks again!

Highlighted
Community Support
Community Support

Re: Query a SharePoint List to see if item exists

Hi @_sourcecod3_ ,

 

Could you share all the screenshots of the Flow configuration?

In the screenshot I provided, If yes represents that the item does not exist, and if no represents updating the existing item.

Moreover, the Condition is used to judge whether the item exists or not, and is not used in Apply to each.

If the item does not exist, do not use the Dynamic content contained in Get items when configuring Create item action.

26.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper III
Helper III

Re: Query a SharePoint List to see if item exists

@v-bacao-msft thank you! this worked. I was ble to figure out the condition using your example. 

 

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (8,719)