I have an SPFX application where the user can visualise a number of files stored in SharePoint. The files are open on an IFrame on the left that points to Office Online while the metadata are displayed on the right.
When the user edits the data the application calls a webservice where I modify the metadata of the files in the folder of the document using CSOM. But, because the file is open in Office Online in an IFrame, I get the following error :
'The file "Name of the file" is locked for shared use by User.'
is there a way to manually release the lock on a file opened by a user in Office Online using CSOM ? Or to open a file in office online in a way that it doesn't prevent the file from having its metadata modified ?
Here is the c# code :
Web web1 = clientContext.Web;
clientContext.Load(web1, wb => wb.ServerRelativeUrl);
clientContext.ExecuteQuery();
string path = incoming.SHPLinkedFolder.Replace(SiteUrl + "/", "");
Folder folder = web1.GetFolderByServerRelativeUrl(path);
clientContext.Load(folder);
clientContext.Load(folder.Files);
clientContext.ExecuteQuery();
foreach (File file in folder.Files)
{
ListItem fileItem = file.ListItemAllFields;
clientContext.Load(fileItem);
clientContext.ExecuteQuery();
fileItem["Post_x0020_Stamp_x0020_Date"] = incoming.Post_Stamp_Date;
fileItem["Reference_x0020_Letter_x0020_In"] = incoming.Reference_Letter_In;
fileItem["Title"] = incoming.Title;
fileItem["Document_x0020_Author"] = incoming.Document_Author;
fileItem["Document_x0020_Language"] = incoming.Document_Language;
fileItem["Document_x0020_Date"] = incoming.MailDate;
fileItem.Update();
clientContext.ExecuteQuery();
}
Thanks a lot for your time.