To get the user’s security roles, I used an OData query. After getting the results from the OData query, I saved those results into an array. In order to get the required security role from the array of security roles, I parsed the array of security roles by using the array method “IndexOf”.
userHasRole = userRole.indexOf("Role Name");
To create the code, I used a test Dynamics CRM 2015 online organization. I added a web resource to the OnLoad event of the record and I received the result shown below.
But when I added this code into Dynamics CRM 2011 I received the error shown below:
“There was an error with this field's customized event. Error: Object doesn't support this property or method."
I started debugging and found out that the line “userHasRole = userRole.indexOf("Role Name");”, was causing the error. Returning to my test environment, I verified my code still worked in Dynamics CRM 2015 and also verified it worked in Dynamics CRM 2013. I could not figure out why it was working in these and not in the CRM 2011 environment.
Next I checked my browser settings, Internet explorer version, and everything looked fine. I tried using another browser as well but received the same error that was received in the first browser.
Then I decided to use a different approach instead of “indexOf” to parse my security roles.
1 var RoleName = "Please put your role name here";
4 // Check for security role by looping through array
5 for (var i in userRole)
7 if (userRole[i] == RoleName)
Even though we did not figure out exactly why indexOf did not work in the CRM 2011 environment we were working in, we were able to substitute a different method to get the needed result. Hopefully this will help someone who is having the same issue.
For more information about this blog or C5 Insight, contact us here!
The complementary paper includes over 12 years of research, recent survey results, and CRM turnaround success stories.
This 60-second assessment is designed to evaluate your organization's collaboration readiness.
Learn how you rank compared to organizations typically in years 1 to 5 of implementation - and which areas to focus on to improve.
This is a sandbox solution which can be activated per site collection to allow you to easily collect feedback from users into a custom Feedback list.
Whether you are upgrading to SharePoint Online, 2010, 2013 or the latest 2016, this checklist contains everything you need to know for a successful transition.