Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

What is best method to get GetItemsWithUniquePermissions count from SharePoint 2013 using client context (CSOM)?

$
0
0

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


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>