Storagepipe Is Now Thrive

GridWay Is Now Thrive

Office 365

Power Automate – Avoiding “File Locked For Shared Use” Failing Your Workflow

Power Automate – Avoiding “File Locked For Shared Use” Failing Your Workflow

In our workflows, we often need to perform file metadata updates, check-ins, moves, etc. If a file is locked and we do not account for it, it can fail our workflow entirely and prevent it from moving forward. 

Consider a common scenario of running an approval flow that updates a Status field or other fields based off of the stage of the workflow and end-user responses. Utilizing a “Do until” loop and configuring the “run after” settings of actions we can ensure metadata updates are performed before moving onto the next steps of the workflow.

How does it work?

The basic premise is to create a variable to store the state, then use a Do Until loop to keep trying to update the item. If the update fails, execute a Delay and try again. If it succeeds, update the variable to exit the loop. The Run After conditions need to be set on both the Delay and the Set Variable. The Delay will run when the Update fails or is timed out, while the Set variable will run if the delay is skipped.

1. Initialize a Boolean variable and set it to False.

Update Metadata

2. Create a Do Until loop to run until the variable ‘UpdateMetadata’ = True.

The Change limits configuration controls how long the Do Until loop runs, or how many times it tries before moving onto next workflow actions. I set timeout to PT720H, which is 30 days using the ISO-8601 duration notation, and leave count empty so it retries unlimited times. 

Place your “Update item” or other action susceptible blockage within the Do Until. After the Update item, add a Delay action to configure how long you wish to wait between retries. 

After the Delay, add a Set variable to flip the marker variable to True, indicating the update was successful and the loop can stop.

Creating a Do Until Loop

3. Configure run settings on ‘Delay’ and ‘Set Variable’.

If the Update is successful, the “has failed” and “has timed out” options will instruct the workflow to skip the Delay action and move onto the Set Variable. 

Setting “is skipped” on Set Variable means it will only run if Delay didn’t, which would indicate a successful update.

Delay Run Time

Set Variable Run Time


In a shared environment, there is a good chance you will try to update a file while it is in use by others. When it’s a human being performing the update, the consequences are usually minimal — we just wait a few minutes and try again. When a workflow is blocked, it can cause downstream issues and leave data and files in an unexpected state. By adding some protection and retry logic around the updates, we can help ensure they are completed successfully before moving on to other tasks.