SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the following code behind to update the user of a user field. The property allow multiple users is set for this field. How can I keep the users who are already present in this list and add the new user? (Now the field is cleared and refilled with the new value)

using (SPWeb Web = Site.RootWeb) {                  
SPUser user = Web.EnsureUser(UserName);
SPFieldUserValue fuv = new SPFieldUserValue(Web, user.ID, user.LoginName);
SPList List = Web.Lists["MyList"];
SPListItem item = List.GetItemById(ID);  

Web.AllowUnsafeUpdates = true;
item["MultipleUsersField"] = fuv;
Web.AllowUnsafeUpdates = false;
share|improve this question
up vote 9 down vote accepted

You can use this simple code:

SPFieldUserValueCollection values = (SPFieldUserValueCollection)item["MultipleUsersField"];
values.Add(new SPFieldUserValue(web, user.ID, user.Name));
item["MultipleUsersField"] = values;
share|improve this answer
That's what I was looking for! Thanks Vedran! – Wim Hill Sep 5 '11 at 13:55

See this question I answered the other day: Add users e-mail addresses from multivalue user field to string

I believe you can use that code provided in the link to retrieve the existing collection of users and then add or modify the collection how you please, then set that collection back as the value of the item.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.