Hi,
I have an issue with Excel Files in Document Library.
This code work perfectly with word document but it doesn't work with Excel Files.
Any Idea?
Thank you for your answers.
SPListItem listItem = SPContext.Current.List.GetItemById(itemID); Guid siteGuid = SPContext.Current.Site.ID; Guid webGuid = SPContext.Current.Web.ID; Guid listGuid = SPContext.Current.List.ID; bool allowUnsafeUpdate = false; if (Records.IsRecord(listItem)) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteGuid)) { using (SPWeb web = site.OpenWeb(webGuid)) { allowUnsafeUpdate = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; try { SPListItem li = web.Lists[listGuid].GetItemById(itemID); Records.BypassLocks(li, delegate(SPListItem newItem) { newItem["MetadataGuid"] = flag; newItem.UpdateOverwriteVersion(); }); } catch { //success = false; } finally { web.AllowUnsafeUpdates = allowUnsafeUpdate; } } } }); } else { using (SPSite site = new SPSite(siteGuid)) { using (SPWeb web = site.OpenWeb(webGuid)) { allowUnsafeUpdate = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; try { listItem = web.Lists[listGuid].GetItemById(itemID); listItem["MetadataGuid"] = flag; listItem.UpdateOverwriteVersion(); } catch { //success = false; } finally { web.AllowUnsafeUpdates = allowUnsafeUpdate; } } } }