Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

"When a file is created" Flow for SharePoint Online - Document Locked

(0) ShareShare
ReportReport
Posted on by 47

I have a Flow that triggers on 'When a file is created'. The goal of the Flow is to assign a property to the document. The file is created from the New menu in SPO.

 

The problem with this action is the file will be locked, of course, when the user creates the file. The file automatically opens in the browser (usually) thus is locked for editing.

 

Besides using a random retry interval on the trigger, is there any other solution available? I won't know when the document is unlocked as that would be an indeterminiate amount of time, based on user interaction with that document.

  • Verified answer
    ScottShearer Profile Picture
    25,208 Most Valuable Professional on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked

    @trevorseward 

    Please see my screen shot below and give it a try.  I create a loop and run until a boolean variable equals true.  I am using the run after configuration in the set variable actions to handle the error - this should allow the Flow to proceed until it is successful.

     

    Please note that I haven't tested this (short on time right now...) but I believe it will work for you.

    error1.jpgerror2.jpgerror3.jpg

  • trevorseward Profile Picture
    47 on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked
    A delay is unreliable. This requires you to know exactly how long you must delay for. This isn't something we'll know as a user can have the file open for an indeterminate amount of time. I need a solution to detect the error, handle it, then retry periodically until it succeeds.
  • v-bacao-msft Profile Picture
    on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked

     

    Hi @trevorseward ,

     

    This is related to the file you created the new file. If you upload a file, this problem will not occur.

    Since Word online has an AutoSave mechanism, when you create a new file, even if you don't click Save button, the file will automatically save and trigger Flow.

    At the same time, in order to avoid content confusion when editing files, the file will be locked, so other actions in Flow may not be able to operate on it.

    You could try adding a Delay action in the Flow, waiting for the file to be edited and automatically unlocked to execute the remaining actions.

    Besides, please check this similar thread and see if it helps:

    https://powerusers.microsoft.com/t5/Flow-Ideas/SharePoint-Wait-for-file-to-be-unlocked/idi-p/180922

     

    Best Regards,

  • trevorseward Profile Picture
    47 on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked
    Creating a new file. This action opens the file in the browser, which is the desired behavior.
  • hariskadir Profile Picture
    4 on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked
    Hi Trevor,

    When you said “When a file is created” do you mean uploading file or creating new microsoft office document?

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.
  • trevorseward Profile Picture
    47 on at
    Re: "When a file is created" Flow for SharePoint Online - Document Locked
    Disregard, the Retry Interval will not work for this as the action will simply fail. Any other thoughts?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow