I had a requirement where I wanted to know if a user had a particular system role. I created a function which returned all User Roles with a particular name (System Administrator for example) and compared this to what gets returned from Xrm.Page.context.getUserRoles().
This worked in the Development and Testing environments so it was pushed to Production. When in Production the function failed to recognise the correct Roles which made no sense.
After wasting several hours of my life I discovered that the issue was related to the relationship between Business Units and Roles.
The Production environment had 60+ business entities where Development and Testing had much less. The 60+ business units meant that CRM created 60+ versions of the Security Roles so searching for "System Administrator" returned over 60 records.
The page length for XMLHttpRequest OData requests through the CRM Web Service is fixed at 50.
Rather than repeat the solution here I suggest you look at Lakshman Reddy's blog which is what lead me to my fix.
http://lakshmanindian.wordpress.com/2012/12/07/retrieving-more-than-50-records-using-odata-in-crm-2011/
The only issue I had was the process of returning all those Roles slowed down my CRM page. So I instead reversed my query for example.
Original
Return all Roles with 'System Administrator' name then compare with User Roles.
Updated
Return all Roles where Guid is in User Roles
No comments:
Post a Comment