cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to check if an item exists on a SharePoint list and either create or update

I have a Flow setup to create/update items in a SharePoint list. Users are only allowed to have one "in progress" item at a time, so I've created a view that pulls all items in the list that are "incomplete". Flow then retrieves this view and filters it by the employee number. The condition checks the length of the array of items returned by the view filter. If length is 1, it triggers an email to be sent to the employee telling them to close their previous item before trying to make a new one. If not (i.e. number of items = 0) it creates the item using the user input.

 

This check has worked for all but one user for the past two months. Suddenly I'm having many users with multiple "incomplete" items in the SharePoint list. The Flow runs in question are resolving the condition length = 1 to false despite there being an incomplete item in the list.

 

I have no idea where to begin looking for errors. The Flow is configured correctly and works for all but a few users.

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

Hi @Anonymous,

 

Could you share all the screenshots of your Flow configuration?

I was wondering if you just use email to notify users without restrictions, then the email is just a reminder, and the user may have created multiple items without following your rules.

Perhaps you could consider using approval. When the user wants to create an item, check if the user has an item in the "in progress" state. If there is, delete the item and notify him that the item cannot be created. They need to close the previous item.

Please provide more details and which should be helpful for me to share a further suggestion.

 

Best Regards,

Barry

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.
Anonymous
Not applicable

I'm afraid with the nested condition it will be difficult to get a single screenshot. Here are the steps of the flow:

---------------------------------------------------------------------------------

1. Manually trigger a flow

- User inputs: text, text, text, number, text, choice

 

2. Get items

- select SharePoint list (a few thousand items), filter by username (found by truncating logged in user's email), filter columns by a view of "incomplete" items which will never have more than a few dozen items (this view has been verified to be working)

 

3. Condition: length(body('Get_items')?['value']) is equal to 1

 

If YES:

a. Send me a mobile notification ("Error occurred, check email, etc.")

b. Send email with options:

    i. discard my input, I will go back and finish the item

    ii. automatically update my open item and create a new one

c. Condition: selected option is equal to 3.b.i

    If YES: do nothing

    If NO:

        - apply to each value: update item (fill in missing field supplied by user that defines an "incomplete" item)

        - create item (using original user input)

 

If NO:

a. create item (using user's original input)

--------------------------------------------------------------------------

We also have a second flow that users use to close their incomplete items. It takes the list of incompletes, filters to the logged in user, and adds their input to the correct column. There is a condition that sends an error email if the "filter to user" step returns no items.

 

 

This setup was working perfectly with the exception of one user a few weeks ago who managed to end up with a dozen incomplete items. Then this weekend users were trying to use the second flow and getting the error email even though they had an incomplete item to close. I checked the incomplete items view and found dozens of users who managed to create multiple open items, somehow bypassing the check in the first flow above.

 

I did see that the list as a whole exceeded 5000 items shortly before these issues were reported, but that shouldn't matter as the "Get items" step applies a view to the list, right?

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,970)