Thursday, November 3, 2011

How to update the audit details of a splistitem....



How to add a user in SharePoint
user.ID + ";#" + user.Name;



czWeb.AllowUnsafeUpdates = true;

SPUser user = czWeb.EnsureUser(@"AF\jojo");
SPFile xxx = czWeb.GetFile(@"http://jojo/pricing.xlsx");

xxx.Item["Created By"] = user.ID + ";#" + user.Name;
xxx.Item.SystemUpdate(false);


How to add a user in SharePoint
xxx.Item[SPBuiltInFieldId.Modified_x0020_By] = user.ID + ";#" + user.Name;


This does not
xxx.Item["Author"] = user.ID + ";#" + user.Name;
xxx.Item["Modified By"] = user.ID + ";#" + user.Name;


At certain times, possibly because of versions,
UpdateOverwriteVersion works SystemUpdate will not.

No comments: