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

7 REPLIES 7
ScottShearer
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. 

 

hello @v-bacao-msft 

 

What you suggest if dynamic content is only option & want to create item?

 

Please help..

 

Thanks in Advance!

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (69,032)