EnsureUser using email address in SharePoint client object model -
i need update fielduservalue field in sharepoint 2013. given email address data. can't user ensureuser since accepts logonname. used fromuser method gives me error says "the user not exist or not unique"
fielduservalue user = fielduservalue.fromuser(email);
it worked when tried using email address when use email addresses in data results in error. how fix issue?
you resolve user email address using utility.resolveprincipal method, 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
Comments
Post a Comment