0

I have a document library in SharePoint Online. I want to automatically populate the documents in the library with some metadata upon file creation using Flow/Power Automate. The problem is that SharePoint automatically opens the file in the browser. This means that the file is immediately locked by the user and the Flow cannot update file properties.

Is there a way to avoid automatically opening the newly created file such that the Flow can initialize the metadata? I envision the following behavior: After pressing New->Word Document, I just see a new line appearing in the Library and I can edit the properties. To open the file I would need to explicitly click on the name.

3
  • I now found that there is a function to release a file lock: docs.microsoft.com/en-us/dotnet/api/… That may help to update file properties. Unfortunately, I don't manage to use it from the REST API.
    – erik
    Mar 17, 2021 at 23:13
  • I found a workaround that may be useful for others too: I set up a list, where I create a new item for every newly created document in the document library (using a flow). The list holds the ID of the document in the document library and all the metadata I need to assign upon creation. Afterwards, to update the metadata also in the document of the document library, I have a second flow that tries repeatedly to write back the metadata until it works. Details can be found here: tachytelic.net/2020/11/power-automate-locked-document
    – erik
    Mar 24, 2021 at 9:40
  • Sounds promising. I think you can post this workaround as an Answer so that other forum users can find it more easily. Mar 24, 2021 at 23:56

1 Answer 1

0

I’m afraid that is not possible.

Every item in a document library needs to have an underlying file or folder before you can fill in the item's metadata. And that requires the file to be opened, in browser or in client.

Whenever you try to create a new file without opening but go to the Edit form directly, it will return an error saying:

Error: To add an item to a document library, use SPFileCollection.Add()

And the creation will never happen.

That is the default behavior in SharePoint Online and there is currently no setting or configuration to change it.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.