I need to update a FieldUserValue field in sharepoint 2013. i am only given an email address data. I can't user EnsureUser since it only accepts the logonName. i used the FromUser method but it gives me an error that says "the user does not exist or is not unique"
FieldUserValue user = FieldUserValue.FromUser(email);
it worked when i tried using my email address but when i use the email addresses in my data it results in an error. how do i fix the issue?
You could resolve user by email address using Utility.ResolvePrincipal method, for example:
var result = Microsoft.SharePoint.Client.Utilities.Utility.ResolvePrincipal(ctx, ctx.Web, emailAddress,Microsoft.SharePoint.Client.Utilities.PrincipalType.User,Microsoft.SharePoint.Client.Utilities.PrincipalSource.All, null, true);
ctx.ExecuteQuery();
if (result != null)
{
var user = ctx.Web.EnsureUser(result.Value.LoginName);
ctx.Load(user);
ctx.ExecuteQuery();
}
References