I am working on a console application that updates list items using managed CSOM. I have a user or group column in this list that can contain multiple values. Now, I am using below code to update the value of this column:

// Get the user  
User newUser = web.EnsureUser("LoginName");  
FieldUserValue userValue = new FieldUserValue();  
userValue.LookupId = newUser.Id;

// Update the list item  
listItem["User"] = userValue;

The issue is if I assign the value of user1 to this column, the value that I see after the column is updated is another user; like user2. I don't know why it is populating this code with some other user?

Any idea on this issue?


You should call Update() and ExecuceQuery() at the end of the code as shown here:

 Microsoft.SharePoint.Client.User _newUser = _ctx.Web.EnsureUser("domain\\username");

 Microsoft.SharePoint.Client.FieldUserValue _userValue = new Microsoft.SharePoint.Client.FieldUserValue();
 _userValue.LookupId = _newUser.Id;
 _listItem["userfield"] = userValue;

I suggest you to use Fiddler to see the network traffic between client and server.

  • Yes, I am doing it. Forgot to add that part in the question. I am updating the list item and then firing ExecuteQuery as well. – Mohan Divraniya Jan 15 '15 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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