I see an exception with quick watch:
'listitems.ListItemCollectionPosition' threw an exception of
type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
Here is my code.
Microsoft.SharePoint.Client.ListItemCollection listitems = list.GetItems(query);
context.Load(listitems, items => items.Include(item => item , item => item["MyPerson"]));
context.ExecuteQuery();
User u = null;
foreach (ListItem item in listitems) // a quick watch on listitems shows the exception
{
FieldUserValue fuv = (FieldUserValue)item["MyPerson"];
u = context.Web.EnsureUser(fuv.LookupValue);
context.Load(u, user => user.Email);
context.ExecuteQuery();
res = u.Email;
}
MyPerson corresponds to the internamname of a field, which is person or group
0 commentaires:
Enregistrer un commentaire