SharePoint 2007: Update system properties (Created, Created By, Modified, Modified By)

The system metadata can be changed to any value desired using the object model. I did notice a bug that the "Created By” (aka Author) field wouldn’t update unless also the “Modified By” (aka Editor) field was set (either to a new or it’s current value).

SPListItem item = ...;
item[“Created By”] = web.EnsureUser(“luisb”).ID;
item[“Modified By”] = item[“Modified By”];
item[“Created”] = DateTime.Now.AddYears(-3);
item[“Modified”] = DateTime.Parse(“01/01/2000”);

  • I could only get it to work using UpdateOverwriteVersion and not with SystemUpdate
  • You can use the internal name or ID of the field if working with a different language pack/installation
  • Works both on lists and libraries (not that I doubted this really)

Links to this post


Wednesday, 24 Jun 2009 09:31 by gilles_pubs
Hello, First of all, this instruction : DateTime.Now.ToString.AddYears doesn't compile at all, I guess you need instead : DateTime.Now.AddYears Also, I never make it work to change the "Created" field : as soon as I invoke the UpdateOverwriteVersion() method, the "Created" field is modified and become the current datetime. Thanks for you help.

Wednesday, 24 Jun 2009 09:08 by Steven Van de Craen
Gilles thanks for the heads up. I've fixed the code error. The created date shouldn't be modified when you do the update. Are you not mistaken with 'Modified' ? Also I've found that in order to change the 'Created' fields you need to explicitly set the 'Modified' fields as well (even if you assign them their current value).

Tuesday, 18 Aug 2009 02:42 by Anand
Hi Steven, How we can change the modified column of Page library. The page is under workflow and through code we are approving and publishing the page, but page is publsihing with System Account.Instead of that it should display the user name who has completed the last task.

Wednesday, 19 Aug 2009 12:17 by Steven Van de Craen
Anand, you could execute the above code on it and then do an auto Approve from code (bypassing the workflow), but you would see this in the Version history (no way around that AFAIK).

Thursday, 3 Sep 2009 02:56 by Domenico
I am getting an unauthorized access exception when running the program on the server. I was able to update the Created and Modified fields but when I add the Author and Editor I get that error. Any help will be appreciated. Thanks.

Thursday, 17 Sep 2009 02:09 by Steven Van de Craen
Domenico, did you try this using the System Account just to make sure the user has sufficient permissions ? Are you running from a Web Part or Console App or ?

Tuesday, 29 Sep 2009 08:01 by Domenico
I was not using the System Account. I was not aware that you needed to use the System Account. I got it to work by using the following method. SPSecurity.RunWithElevatedPrivileges(delegate() { // do things assuming the permission of the "system account" }); Thanks for your help anyways.

Saturday, 10 Oct 2009 04:25 by Peter Holpar
Hi Steven, Thanks for sharing this trick. Based on that I've created a little tool in the form of a custom field that one can use to set these properties from the standard WSS 3.0 / MOSS 2007 list item edit user interface. Hope that helps someone.!2CD45589973F2849!200.entry Regards, Peter

Wednesday, 7 Jul 2010 06:35 by Deependra
Hi, I was using Runwithelevatedprivilege block to upload a file to the document library. But once uploaded the "Created By" and "modified By" field display System Account. I tried the following: addedFile["Author"] = addedFile["Uploaded"]; addedFile["Editor"] = addedFile["Editor"]; addedFile.UpdateOverwriteVersion(); But immediately after this an error is thrown reading: Url is invalid.It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web. Please help!!!

Monday, 22 Nov 2010 07:52 by Milind Nikam
Hi, Can we add user in "modified by" field which is not in Active Directory? Like item[“Modified By”] = "Any Name" Any help would be appreciated. Thanks in advance, Milind

Monday, 22 Nov 2010 08:24 by Steven Van de Craen
Milind, you can't. The user (SPUser) has to exist. If you want to avoid Active Directory you could set up FBA to a different user store and set the field to an FBA user ? But it might be too much effort for what you're trying to do.

Thursday, 6 Jan 2011 07:20 by Olga D
Thank you so much for this post! I tried all possible update methods during previous day, field read only set to false and nothing worked until I have updated ALL fields as you have mentioned with UpdateOverwriteVersion. it worked in my 2010 sharepoint doc library like a charm! thank you again.

Tuesday, 8 Feb 2011 06:21 by Jigar Sarvaiya
The full Code which can be used, using (SPWeb web = site.OpenWeb()) { web.AllowUnsafeUpdates = true; SPList list = web.Lists["Shared Documents"]; //SPListItem item = list.Items.GetItemById(4); SPListItemCollection lColl = list.Items; foreach (SPListItem item in lColl) { //item["Title"] = "AAAAAAAAAAA"; //item["Description"] = "New Test"; SPUser user = web.EnsureUser("ss000019"); string usr = user.ID + ";#" + user.Name; SPUser user1 = web.EnsureUser("ssos000020"); string usr1 = user1.ID + ";#" + user1.Name; item["Author"] = usr; item["Editor"] = usr1; item.Update(); } list.Update(); web.Update(); web.AllowUnsafeUpdates = true; } NOTE: to update Created By it is necessary to change Modified By also because whenever u make any changes at item level it requires the user who makes changes...

Saturday, 16 Jul 2011 05:51 by jin
Thanks Steven for sharing this. You post helped us a lot on our project of moving our cross site document libraries.

Thursday, 4 Apr 2013 02:59 by david boeme
How do you update system properties (Created, Created By, Modified, Modified By)in SharePoint 2010?

Wednesday, 27 Nov 2013 01:40 by Vladimir
Thanks a lot. You save me from recreating items

CAPTCHA Image Validation