In a comment on Tip 211: When upgrading, don’t forget the team form, Pebo asked “what about the possibility for showing roles in subgrids of teams and user forms?”
This is a great question, and we have an answer.
First, you need to understand security roles in Dynamics CRM. There is not just one record for each role. There is a copy of each security role for each business unit. If you add a subgrid of related security roles to the team or user record, it will not show related security roles on the form. This is because the only view that the subgrid definition allows you to pick is the “All Roles” view.
The problem is this view filters out the business unit specific roles, so when you view your user or team form, the subgrid is blank, even though the user or team has security roles.
Security Role is also one of the few entities where the views cannot be customized. You cannot create new system views or edit existing views. The subgrid works, but the view filters out the records that we want to show.
Thanks in part to this post, I was able to make the related roles subgrid work correctly.
- Insert a subgrid on the user or team form. In this case I called it “User_Roles” and selected to show only related Security Role records, then save and publish the entity.
- Go settings–>Customization–>Customize the System. Expand the Security Role entity customization and go to “Views.” Open the definition of the “Role Associated” view. Click “Actions” and “Email a link.”
- From the link, we can get what the GUID of the Role Associated View.
- Export a solution containing the team and/or user entities, where your subgrid lives. Extract the .zip file and open the customization.xml file in the XML editor of your choice.
- Search for your subgrid name. In this case “User_Roles.” Replace the ID in the <ViewId> line with the ID copied in step 3.
- Save the xml file, zip it up, import, and publish.
Now when you open your user record, you can see the security roles associated with the user.
But is it supported?
So the question that you may be asking is, this sounds great, but is it supported? Given that Microsoft does not allow changing of the view associated with the subgrid via the user interface, does that mean that doing so via XML surgery is unsupported?
As illustrated in the blog post linked above, Microsoft has built in capabilities like subgrid deep linking and fetch left outer joins that are not exposed through the user interface. Sometimes they actually recommend it. So editing the XML in itself does not make something dangerous or unsupported, as long as you know what you are doing. Microsoft has not tested this exact scenario, but it is safe and only will cause a problem if the view referenced by that GUID does not exist.