Fixing Locked File Error in Power Automate

file lock

A common issue faced by users of Microsoft Power Automate (formerly MS Flow) is the file lock problem. This happens when a file is stored in SharePoint, OneDrive, or other cloud storage, is locked and cannot be accessed or modified by the flow.

A locked file means that it’s currently in use by another user, preventing your flow from performing its actions on the file like update file properties.

Why Does a File Get Locked in Power Automate?

A file can be locked for several reasons, including:

  1. Another User is Editing the File: If a user has the file open (e.g., in Excel or Word), it may be locked and unavailable for your flow to access.
  2. Multiple Flows Accessing the Same File: If several automated flows are trying to access or update the file simultaneously, a lock can occur.
  3. File Syncing or Ongoing Operations: Files being synced (e.g., in OneDrive or SharePoint) may temporarily be locked while the sync is in progress.

How to Fix Locked File Errors in Power Automate-

You can fix this issue by using the Do Until loop action in your flow. If your flow is relatively simple and doesn’t involve updating file properties in multiple places, then using a Delay action might be enough. However, if your flow updates file properties at different stages, simply using a delay could cause errors in those other update actions. In such cases, the Do Until loop provides a more reliable solution to handle locked files effectively.

Approach-

  1. Initialize a boolean variable and set its value to false.
  2. Then, use a Do Until loop around the action where you are updating file properties.
  3. Set the loop condition to continue running until the boolean variable is set to true.

Flow Design-

flow design for lock file

Configure your delay run after like this-

Delay Config

Note: Set your delay as per your Do until Count and Timeout limits. For more info click here.

Conclusion

Dealing with locked file errors in Power Automate can be frustrating, but with the right step in place, you can reduce the impact and ensure your flow run smoothly. By implementing these steps you’ll be able to keep your Power Automate flows running smoothly, even when dealing with locked files.