In the code below I am getting the following Exception :
Unhandled Exception: Microsoft.SharePoint.SPException: The file Audit/0003 has been modified by contoso\sp_install.
Does the file need to be checked out first? Anyone has got any idea how to solve this? I can't seem to find example on how to add an item to a document set.
SPList list = web.Lists.TryGetList("Audit");
DocumentSet docSet = CreateDocumentSet(list, au.Guid);
SPListItem docSetItem = docSet.Item;
if (list != null)
{
docSetItem["A1_1_Question"] = au.A1_1_Question;
docSetItem["A1_2_Question"] = au.A1_2_Question;
docSetItem.Update();
}
public static DocumentSet CreateDocumentSet(SPList list, string DocumentSetName)
{
SPContentType docsetCT = list.ContentTypes["Audit"];
Hashtable properties = new Hashtable();
properties.Add("DocumentSetDescription", "New Document Set");
SPFolder parentFolder = list.RootFolder;
DocumentSet docSet = DocumentSet.Create(parentFolder, DocumentSetName, docsetCT.Id, properties, true);
return docSet;
}