문제

I have the following CSOM code:

Group group = web.SiteGroups.GetByName(subsitename);                     
List<FieldUserValue> currentgroupUsers = new List<FieldUserValue>();
foreach (User user2 in group.Users)
{
     currentgroupUsers.Add(***********);
}

So how I can convert/cast a User object to FieldUserValue object?

도움이 되었습니까?

해결책

Try something like below:

List<FieldUserValue> currentgroupUsers = new List<FieldUserValue>();

foreach (User user2 in group.Users)
{
    var userLookupValue = new FieldLookupValue { LookupId = user2.Id };
    currentgroupUsers.Add(userLookupValue);
}

oListItem["PersonOrGroupField"] = currentgroupUsers.ToArray();
oListItem.Update();
context.ExecuteQuery();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top