I’m converting Event receiver codes into Remote event receiver using SharePoint 2013 Client context. I need to get list items with unique permissions count to validate while creating new document in certain site collections
It is possible using SharePoint object model
SP.List.GetItemsWithUniquePermissions().Count()
I written the below logic to get list items with unique permissions count in CSOM but it is throwing timeout exception
var items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items, icol => icol.Include(i => i.RoleAssignments.Include(ra => ra.Member), i => i.DisplayName));
ctx.ExecuteQuery();
List<string> uniqitem = new List<string>();
foreach (var item in items)
{
foreach (var assignment in item.RoleAssignments)
{
uniqitem.Add(assignment.Member.Title);
}
}
int itemCount = uniqitem.Distinct().Count();
Could you please suggest me the right method in CSOM ? Thanks in advance
Thanks, it is slight faster now
var items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items, col => col.Include(i => i.HasUniqueRoleAssignments));
ctx.ExecuteQuery();
int itemCount = items.Where(i => i.HasUniqueRoleAssignments).Count;