How to change the value of “Created By” field in MOSS

SPSite site = new SPSite(siteUrl);

SPWeb web = site.OpenWeb();

web.AllowUnsafeUpdates = true;

SPList list = web.Lists["Test"];

SPListItemCollection collection = list.Items;

foreach (SPListItem item in collection )


SPUser user = web.EnsureUser("UserName");

string value1 = user.ID + ";#" + user.Name;

item["Author"] = value1; //for Created By field

item["Editor"]=value1 ;  //Modified By field

item.Update();  //Update the item




Its not necessary that same user should be logged in.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s