I don't think it is possible, but hoping I am wrong. I'm using a CSOM in a C# application to update a SharePoint list (SharePoint Foundation server). All of the items on the list are updated correctly, except for the 'Author' column, which is person or group value. When I check the SharePoint list, it is always updated with the current user executing the application (me).
Is there a way to add other users to SharePoint list? I have the their IDs and all other needed data. I thought I could with EnsureUser, but seem to be wrong. Below is the sample code that I use.
Any help is appreciated, thank you.
ClientContext clientContext = new ClientContext(sharepointContext); List sharepointList = clientContext.Web.Lists.GetByTitle(listName); User newUser = clientContext.Web.EnsureUser("domain\\login"); //random user info clientContext.Load(newUser); clientContext.ExecuteQuery(); FieldUserValue userValue = new FieldUserValue(); userValue.LookupId = newUser.Id; ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem oListItem = sharepointList.AddItem(itemCreateInfo); oListItem["Author"] = userValue; oListItem.Update(); clientContext.ExecuteQuery();