none
Changing Created By on SharePoint's hidden user-list - User Information List RRS feed

  • Question

  • Experts,

    Experts,

    I have a SharePoint list to store user information. This list is the hiddent list and is automnatically created by the Sharepoint and add user automatically once they are active. It copies them from the companies server .  So in the 'Created By' field for each list item has different admins ID.
     
    So what I want is to modify the 'Created By' field value for each list item and set it to the respective user's login ID.
    I have triend with workflows but as its hiddent it will not allow me to set up workflow on it as its hidden list. I not even sure it will work from Workflow!
    There is option of SQL code available but I dont know where to edit this code or where on sharepoint I can add this code. Has never use SQL on sharepoint.

    Please help.

    Regards,
    Rushita
    Friday, March 18, 2011 11:18 AM

Answers

  • I don't understand why its important to change the auditing information on the user information list.

    You can update the Created By field (internal field name Author) and Modified By field (internal field name Editor) by manipulating the list item.  You need to do the update as System Account and use SystemUpdate, not Update method.  You should do this on lists but not the User Information List even though it is a List.

    SPUser user1 = web.EnsureUser("user 1 login");
    SPList list = web.Lists["list title"];
    SPListItem item = list.GetItemById(1); // item with id 1
    item["Author"] = user1;
    item.SystemUpdate(false);
    
    

     

     


    Brian Bedard, MCTS - pioneeringsharepoint.blogspot.com - Twitter:@tigertoy

    • Marked as answer by Porter Wang Tuesday, March 22, 2011 3:31 AM
    Friday, March 18, 2011 4:42 PM

All replies

  • I don't understand why its important to change the auditing information on the user information list.

    You can update the Created By field (internal field name Author) and Modified By field (internal field name Editor) by manipulating the list item.  You need to do the update as System Account and use SystemUpdate, not Update method.  You should do this on lists but not the User Information List even though it is a List.

    SPUser user1 = web.EnsureUser("user 1 login");
    SPList list = web.Lists["list title"];
    SPListItem item = list.GetItemById(1); // item with id 1
    item["Author"] = user1;
    item.SystemUpdate(false);
    
    

     

     


    Brian Bedard, MCTS - pioneeringsharepoint.blogspot.com - Twitter:@tigertoy

    • Marked as answer by Porter Wang Tuesday, March 22, 2011 3:31 AM
    Friday, March 18, 2011 4:42 PM
  • Hi Brian,

    I tried this but it's not working for me. No matter what the user I give it is taking the logged in user information and updating.  I am running the script on the machine where I have the sharepoint list.

     

    Thanks

    Ranjith

    Tuesday, June 14, 2011 7:51 PM