I have the need to create Sharepoint blog comments by code:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
sw.AllowUnsafeUpdates = true;
SPList spList = SPContext.Current.Web.Lists["Kommentare"];
SPListItem listItem = spList.Items.Add();
listItem[listItem.Fields["Titel des Beitrags"].InternalName] = SPContext.Current.Item["Title"];
listItem[listItem.Fields["Titel"].InternalName] = titlearea.Value;
listItem[listItem.Fields["Textkörper"].InternalName] = CommentArea.Value;
listItem[SPBuiltInFieldId.Author] = curUser;
// listItem[SPBuiltInFieldId.Modified] = curUser;
listItem.Update();
//spList.Update();
sw.AllowUnsafeUpdates = false;
});
but I allways get a "Invalid data has been used to update the list item. The field you are trying to update may be read only"
I tried Systemupdate and the values seem to be valid.
Has Anybody an idea?
Greetings ren