Trigger Flow when document in SharePoint has been checked-in
-
30-01-2021 - |
Domanda
I need to start an approval when a document in a SharePoint online document library has been checked in. The approval must start when the editor is not equal to the responsible of the document. The responsible is added to the metadata of the library.
For that I'm using Flow but I got no trigger for that. There is only a trigger for when a document is created or edited. How can I make a workaround for that?
The reason why I don't want to trigger when a document is created or edited is because if the editors saved temporary, the flow run with an unfinished document. When it's checked in, the document is finished and then it has sense that the approval needs to start (when the condition for that evaluates successfully).
Question continuous here: Change a document metadata when it's checked out using Flow.
Soluzione
You can use "Edited" trigger, but check document status using "Send an HTTP request to SharePoint" action.
You can use below REST query to get the document with status
_api/web/GetFileByServerRelativeUrl(@FileUrl)?@FileUrl='/sites/your-site/Docs/File.docx'&$select=CheckOutType,Level
- 0: online
- 1: offline
- 2: none
- 1: published
- 2: draft
- 255: checkout
So you can check these properties in order to determine the state of a file and making a decision if flow should continue.
Additional reading: Checking if a SharePoint 2013 Page is Checked Out or Published with JavaScript and REST