SOLVED

Sharepoint Online REST API - Determine if a document is opened

%3CLINGO-SUB%20id%3D%22lingo-sub-2798401%22%20slang%3D%22en-US%22%3ESharepoint%20Online%20REST%20API%20-%20Determine%20if%20a%20document%20is%20opened%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2798401%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20community%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20kindly%20request%20your%20assistance%20for%20the%20following%20problem%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EUsecase%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EUsers%20collaborate%20on%20office%20documents%20(ListItem)%20in%20SharePoint%20Online%20(System%20A).%20After%20they%20are%20finished%20working%20on%20the%20document%20it%20will%20be%20transferred%20to%20another%20document%20management%20system%20(System%20B)%20and%20saved%20there%20as%20a%20new%20document%20version.%20After%20successfully%20transferring%20the%20document%20it%20will%20be%20deleted%20from%20the%20SharePoint.%3C%2FP%3E%3CP%3EAll%20the%20documents%20in%20the%20SharePoint%20will%20be%20periodically%20checked%20via%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fsp-add-ins%2Fget-to-know-the-sharepoint-rest-service%3Ftabs%3Dhttp%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ESharePoint%20API%3C%2FA%3E%20from%20an%20ERP%20System%20(System%20C)%20wether%20users%20are%20still%20working%20on%20it.%20To%20determine%20if%20a%20user%20is%20working%20on%20it%20we%20want%20to%20look%20if%20the%20document%20is%20still%20opened.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EProblem%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EHow%20to%20determine%20via%20Sharepoint%20API%20if%20a%20document%20is%20still%20opened%20by%20a%20user%3F%3C%2FP%3E%3CP%3EPotential%20solution%20would%20be%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fmicrosoft.sharepoint.spweb.recycle%3Fview%3Dsharepoint-server%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Erecycle%20(action)%3C%2FA%3E%20the%20document.%20If%20it%20is%20still%20opened%20it%20will%20be%20blocked.%20But%20if%20the%20document%20is%20closed%20we%20have%20to%20restore%20it%2C%20get%20the%20stream%2C%20transfer%20it%20to%20the%20document%20management%20system%20and%20then%20delete%20the%20document%20in%20order%20to%20fulfill%20the%20requirements.%20This%20chain%20is%20prone%20to%20errors%20and%20we%20would%20prefer%20a%20property%20to%20determine%20if%20or%20by%20whom%20a%20document%20is%20opened.%20Any%20suggestions%20would%20be%20highly%20appreciated%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313910i1009874729248E3C%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20kind%20regards%2C%3C%2FP%3E%3CP%3EOliver%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2798401%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Dear community,

 

I would kindly request your assistance for the following problem:

 

Usecase

Users collaborate on office documents (ListItem) in SharePoint Online (System A). After they are finished working on the document it will be transferred to another document management system (System B) and saved there as a new document version. After successfully transferring the document it will be deleted from the SharePoint.

All the documents in the SharePoint will be periodically checked via SharePoint API from an ERP System (System C) wether users are still working on it. To determine if a user is working on it we want to look if the document is still opened.

 

Problem

How to determine via Sharepoint API if a document is still opened by a user?

Potential solution would be to recycle (action) the document. If it is still opened it will be blocked. But if the document is closed we have to restore it, get the stream, transfer it to the document management system and then delete the document in order to fulfill the requirements. This chain is prone to errors and we would prefer a property to determine if or by whom a document is opened. Any suggestions would be highly appreciated?

 

image.png

 

With kind regards,

Oliver

3 Replies

In case anyone has experience with the descirbed problem a pointer in the right direction would be highly appreciated.

best response confirmed by D365FOoliver (New Contributor)
Solution
I don't think this is possible. I had a similar requirement for a project some time ago and when looking at the APIs I could not find anything that would tell me that a document was open - which I was not expecting to find as this is processing on the client side and the server only needs to be aware of updates
Thanks for the answer, Joel . It confirmed what I expected.
I have now implemented the solution design described in the Problem section of my initial post and it works, but it needs alot of tracking and error handling.