cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

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
Super User III
Super User III

@_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

@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.

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.

@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!

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

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

 

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (6,936)