sharepointspuserfield

Updating User field in SharePoint


I am harnessing batch update of SharePoint list in order to update my list items. I have a field of SPUser type named as 'UserName'.

If i try to update the value of that particular field using batch, am obtaining unexpected error.

I tried out both the username as well as the ID of the user. It was futile. How could I update a SPUser field in batch update? Any responses would be warmly welcomed

Regards, Raghuraman.V


Solution

  • Have you tried setting the value to ID;#Username? ID is the SPUser.ID and Username is really just the display name or account name. Ex: 42;#Raghu.

    Keep in mind, that a particular user's ID changes depending on what Site Collection you're working in (the same user in Site Collection A may have a different ID in Site Collection B).

    You may have to use SPWeb.EnsureUser to make sure the user exists on the web you are trying to update.