SharePoint/WSS: Modify “created by” field?

All -

I am using WSS 3.0. Currently, HR will upload an employee's internal company resume to a document library on our site, but for privacy reasons, we must then restrict access to that document library, which forces users to then go through HR each time they want to update their resume.

My thought is to create a list with attachments enabled that allows users to only view/edit their own items, and then give HR permission to manage all entries. This works with the exception that HR will need to create the initial list item and attach the resume, which means the list item will be "created by {hr}" and not visible/editable by the end user whose resume is attached.

Any ideas on how I can either allow HR to modify the "created by" field on upload so end users will see and can edit their resume, or go about this in a different way?



Create a document library to hold the resume's. Then give the HR department (SharePoint User group) "read / write all" permissions on the library, the give everyone else read / write your own" rights. Create a Content Type called "Resume" based on the out-of-the-box Document content type. Then add a field that contains the Employee (SPUser field) whom the resume concerns to the content type (and any other fields required, i.e. name, address etc.). Have HR fill this in correctly when creating the listitem (make the fields required).

Then, write a itemeventreceiver bound to the content type you just created and override the ItemUpdated event.

The code would be something like the following:

public override void ItemUpdated(SPItemEventProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate { using (SPWeb web = properties.OpenWeb()) { web.AllowUnsafeUpdates = true; var item = web.Lists[properties.ListId].GetItemById(properties.ListItemId); if (item != null) { if (item.Fields.ContainsField("Employee")) { item["Author"] = item["Employee"]; // Author is the internal name of the Created by field, // always use Internal Names! DisableEventFiring(); item.SystemUpdate(); EnableEventFiring(); } } } }); }

you can bind the ItemEventReceiver using a FeatureReceiver to the content type like so:

SPContentType docCt = web.ContentTypes[new SPContentTypeId("CONTENTYPE ID GOES HERE")]; docCt.EventReceivers.Add(SPEventReceiverType.ItemUpdated, "ASSEMBLYNAME, Version=, Culture=neutral, PublicKeyToken=TOKEN", "FULLY QUALIFIED CLASSNAME"); docCt.Update();


Why not just use a document library for the resumes? (instead of a list w/ attachments.) You can give HR full read/write to all documents within, and the owner of the resume will have contribute permissions to only their own resume.


I found a way to change the Created By field using SharePoint Designer to create a workflow.

<ol> <li>Create a dummy field in your list with an easy-to-spot name, e.g. XYZZY. Make it a "person or group" field.</li> <li>In SharePoint Designer, create a Workflow for your list. Allow manual start and start automatically when new item is created.</li> <li>Actions -> Set Field in Current Item -> Set XYZZY to the field in your list that contains the user account you want to put into Created By.</li> <li>Click Finish</li> <li>Now, open your workflow .xoml file with Notepad. Replace "XYZZY" with "Author". Save the .xoml file.</li> <li>Open the workflow in Designer. Click Finish so that it reprocesses with the new code.</li> <li>Delete the dummy field from the list.</li> <li>Run the workflow on each existing item in your list. New items will self-correct automatically.</li> </ol>


With a custom upload screen you could change the context of the current user before doing the upload. It requires looking up the user token using something like the following (these are snippets of working code with error handling and other stuff removed). Note that EnsureUser will require that the current user basically be an admin/owner.

using (SPSite site = GetImpersonatedSite(runAsUser)) { using (SPWeb web = site.OpenWeb()) { // Do stuff here } } private SPSite GetImpersonatedSite(string username) { user = SPContext.Current.Web.EnsureUser(username); SPSite site = new SPSite(SPContext.Current.Web.Url, user.UserToken); return site; }


I had a similar situation (migration into sharepoint) where I had to add a file with the admin user to a doc library and then "change" the users. I did it like this, might help you somewhat:

using (var root = site.RootWeb) { var users = root.SiteUsers; var user = users["domain\username"]; file.Item[SPBuiltInFieldId.Created_x0020_By] = user.ID; file.Item[SPBuiltInFieldId.Modified_x0020_By] = user.ID; file.Item.UpdateOverwriteVersion();


  • reformat multidimensional array based on value
  • Assembly program crashes on call or exit
  • How can I display changed line in Emacs?
  • Complex conditional element in accumulate in Jess rules
  • How to get a specific type object from an Object Vector in Java
  • Changing “Created By” in Sharepoint 2007
  • replacement of asp:Treeview for ASP.NET MVC application
  • What's effective way to write Vaadin project ?
  • deploy SQL Server Database with a Winforms app
  • Symfony2 Form is always empty after submitting
  • Single Table Inheritance in Rails 4
  • Counterintuitive design of addition/subtraction between numbers and nullable numbers [closed]
  • Can't map Ctrl + minus in Emacs in Mac OS X
  • Can TextIO write to prefixes derived from the window maxTimestamp?
  • JSF binding with setValueExpression read-only?
  • Connection between Node.JS and PHP via UNIX Socket - EPIPE write error
  • Why are the debugger memory windows not available in VS 2015?
  • Preventing subclasses overriding methods
  • Gson serializing Spring beans
  • Intellij Idea Terminal shortcut not working
  • Express displaying mongodb documents in Jade
  • Calling C function from lua
  • TextToSpeech.setEngineByPackageName() triggers NullPointerException
  • Does Mobilefirst provide a provision to access web services directly?
  • Time complexity of a program which involves multiple variables
  • Meteor: Do Something On Email Verification Confirmation
  • Cannot resolve symbol 'MyApi'
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Matrix multiplication with MKL
  • AngularJs get employee from factory
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • using HTMLImports.whenReady not working in chrome
  • how does django model after text[] in postgresql [duplicate]
  • Does armcc optimizes non-volatile variables with -O0?