Copy user field value to SharePoint online site
-
08-02-2021 - |
Question
I have a user field in a list that has allow multiple user setting on. ie I can have more than one user in the field. I am trying to copy my User field data form on prem SP2016 site to online site. But nothing is getting copied. Same logic is working if I am running it for two lists in same site but in case of two different sites it is not working.
Below is the code I am using :
//To get form source list
FieldUserValue[] users = null;
users = (FieldUserValue[])item["User"];
//to copy on target list
var listItemCreationInformation = new ListItemCreationInformation();
ListItem newItem = targetlist.AddItem(listItemCreationInformation);
newItem["User"] = users;
newItem.Update();
targetlist.Update();
ctx.ExecuteQuery();
Anyone having idea what might be going wrong.
La solution
Found an article related to assigning multiple users in user and field grouphere
Hope it will help others too.