Reputation: 564
I am attempting to add multiple users to a field using CSOM. However, only one person is being added even though both have been validated.
var newUserField = new List<SP.FieldUserValue>();
newUserField.Add(new FieldUserValue { LookupId = 14 });
newUserField.Add(new FieldUserValue { LookupId = 11 });
newListItem["MultiUserField"] = newUserField;
newListItem.Update();
ctx.ExecuteQuery();
That code always only adds user 14. I have also tried:
newListItem["MultiUserField"] = newUserField.ToArray();
Every reference I have seen says this should work, and it's not throwing any errors.
I have also verified the column allows multiple entries, and have added both users manually as a test. Could this be a document library CSOM limitation? Most references I have seen are using a list.
Upvotes: 0
Views: 2285
Reputation: 564
It turns out, during validating my users, I was calling a
ctx.ExecuteQuery();
that was wiping out what I had saved for the user. Validating the users first and storing their IDs in a list and then updating the item worked.
Upvotes: 1