Ofcourse, you can. Created By & Modified By columns are "Person or Goup" type columns. In SharePoint all the lists has these columns by default. You can't update the values of these columns from UI. But, you can do it through SharePoint APIs.
I have created .NET windows based application to update the "created by" and "modified by" columns using SharePoint APIs. I am giving the sample code snippet below.
/******** Code snippet for modifying the Created by and Modified by column values of a SharePoint List *******/
/******** Written in .Net Windows Based Application **********/
private void button3_Click(object sender, EventArgs e)
SPSite oSite = new SPSite("http://<SiteName>/");
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["TestCustomList"];
SPListItemCollection oListCollection = oList.Items;
foreach (SPListItem oListItem in oListCollection)
SPFieldUserValue oUser = new SPFieldUserValue(oWeb, oWeb.CurrentUser.ID, oWeb.CurrentUser.LoginName);
// or you can hard code the value like this,
SPFieldUserValue oUser = new SPFieldUserValue(oWeb, 14, "Sowmyan Soman");
oListItem["Author"] = oUser;//created by column value = "14;#Sowmyan Soman"
oListItem["Editor"] = oUser;//modified by column value = "14;#Sowmyan Soman"
SPSite oSite = new SPSite("http://<site URL>");
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["TestDocLibrary"];
SPListItem oListItem = oList.Items.GetItemById(5);
Updated : November 13 - 2008
The above code will not update the "created by" column of document library type SharePoint lists. The above code (both) will work just fine for all the lists and even it will update the "Modified by" column in SharePoint document libraries. One of my MS colleagues Vedant has posted a work-around to accomplish this update and you can find it out here
If anyone one want to know how we can do this same functionality using Powershell (codename : Monad) please see Tedd's post : http://blogs.msdn.com/tadd/archive/2008/05/22/updating-the-created-by-and-modified-by-columns-in-sharepoint-lists.aspx
In our discussion board the 'Modified By' column takes the name of the person who last changed the subject not contributed to the discussion.
Is there a way to have the 'Modified By' field take the name of the last user to edit/contribute to the discussion thread?
have you tried to attach an event handler try to modify the column by disabling and enabling the event in the code ?
You can also edit the created by value using a custom form and a Sharepoint:FormField pointed to Author.
Only people with full control of the list will be able to edit though, for some reason.
Hi Sowmyan, can the discussion board's createdby & modifiedby fields be replaced with "Anonymous" through coding ? If so, please help with sample code.
I saw the code but how can I apply that code to the sharepoint site or page?
You can actually update the author on a document library, but you must update the Author and the Editor fields, and call UpdateOverwriteVersion() on the item.
You will most likely want to modifiy the vti_author property too. Assuming $itm is a valid item reference here is some powershell to accomplish the modification-
$itm["Author"].tostring() #show current author
$itm["Author"] = $oUser #list item author
$itm.Properties["vti_author"] = $oUser.User.LoginName #file properties author
$itm["Editor"] = $oUser #this needs to be changed as well to update the item.
$itm["Author"].tostring() #print the changed author
Thanks sowmyancs ,great job u really make my work easier :)
I'v problem following trouble with my SharePoint, I a site owner I can see the contents of the fields: Createdby and modify by but the user of my site cann't see the contents of thies both fields, do you have any idea?
Thanks in advance
I have a user that was lock on to SharePoint as a deferent user for a week and we locked him on as himself, but now when he modifies a document or does something in SharePoint 2010 it shows that it was modified by the user he was locked in as. Can anyone help me with this?