Hi @sweetu ve ,
For updating list item fields (lookup/multiline text/person field and system Modified By field), please refer the following sample:
string password = "********";
string account = "user@Tenant.onmicrosoft.com";
var secret = new System.Security.SecureString();
foreach (char c in password)
{
secret.AppendChar(c);
}
var credentials = new SharePointOnlineCredentials(account, secret);
using (ClientContext ctx = new ClientContext("https://Tenant.sharepoint.com"))
{
ctx.Credentials = credentials;
var web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
var list = ctx.Web.Lists.GetByTitle("CopyItemList");
ListItem item = list.GetItemById(1);
FieldLookupValue lookupFieldValue = new FieldLookupValue();
lookupFieldValue.LookupId = 2; // The lookup Id, modified with yours
User user = ctx.Web.EnsureUser("user@tenant.onmicrosoft.com");
User modifiedUser = ctx.Web.EnsureUser("user@tenant.onmicrosoft.com");
ctx.Load(item);
ctx.Load(modifiedUser);
ctx.Load(user);
ctx.ExecuteQuery();
FieldUserValue fieldUserValue = new FieldUserValue();
fieldUserValue.LookupId = user.Id;
FieldUserValue modifiedUserValue = new FieldUserValue();
modifiedUserValue.LookupId = modifiedUser.Id;
item["PersonField"] = fieldUserValue;
item["LookupField"] = lookupFieldValue;
item["MultiLineField"] = "This is MultiLine Value";
item["Editor"] = modifiedUser;
item.Update();
ctx.ExecuteQuery();
}
For copying list item into another list, please refere the sample here:
Learn About Copying List, List Fields And List Items Using CSOM
Thanks
Best Regards
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.