2

I'm trying to know whether documents is already opened or not by other users, (or I have open the doc) for this, I'm updating the columns and then I'm checking for 423 error like The file "https://xyz.sharepoint.com/sites/TestSites/sites/XYZ Report.docx" is locked for shared use by newuser@domain.com, then I become to know document is already open. Is there any other way to find the opened document without updating the column.?

0

The document is locked. The document gets locked in SharePoint. It shows that document is opened already or it has been checked out to some other users. If that happens you can clear the office cache from C:\Users\Username\Appdata\Local\microsoft\Office\15.0\OfficeFileCache .You can follow this link enter link description here for more on SharePoint document lock out.

0

Whenever a file is checked out, open, or being edited by someone else, a SPFile.LockId property is assigned to it, which is of type string. This is nothing but a GUID assigned to it. Otherwise, it is null by default (when the file is not open). The below code snippet can check if the file is open or not -

string lockStatus = SPFile.LockId;
if (lockStatus == null)
{
   //code for file operations
}

else {
    //unlock, check-in, etc. the file
    //or, use the property "LockedByUser" 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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