In Dynamics 365, security roles are important. They control how teams access different types of records. Existing security roles can be leveraged, as well as new security roles created, to control privileges granted to teams. An administrator may want an easy way to look at assigned security roles. Displaying team security roles using a sub-grid of the Security Roles entity isn’t possible because the only view that is available for selection is the “All Roles” view. When a sub-grid for the Security Role entity is added to a team form, it doesn’t display any records. This is because there is a copy of each security role for each business unit and the “All Roles” view filters out business unit specific roles. Also, the views related to the Security Role entity cannot be edited and new views cannot be created.
This problem was originally identified and a solution presented in this post. However, this solution was viable only prior to the Unified Interface. Now, with Unified Interface, embedded canvas apps present a very simple solution to this problem. This is a follow-up to this post where I have presented a solution to display security roles for users.
Here is a detailed step-by-step guide to create this embedded canvas app (a summarized description is at the end of the article):
- First, add a section to an existing tab (or on a new tab) of the Team entity main form and add any required field to this section (a required field ensures the app will refresh in response to any change in data on the host model-driven form). As an example, I added a new section “Team Roles” to the General tab and added the ‘Team Type’ field:
- After adding a field, double click on it to access the field properties. Go to the Controls tab and select “Add Control.” Select “Canvas App,” set it as the Web option, and click on “Customize” (the App ID will be blank):
- This will open the app designer with a predefined screen that has an edit form added to it:
- Add a new list screen, Security Role as a data source, and then a gallery (Title layout or any other type as needed). Set the Items property of the gallery as shown below (side note: in this example, the Text property of the label is set to “Team Roles for: “ & [@ModelDrivenFormIntegration].Item.’Team Name’, and the default icons to refresh, sort, and add are deleted or they can be hidden by setting their visible property to false). Note the ModelDrivenFormIntegration is used only to lookup the user record. Accessing Security Roles using this team record gives only one option (unlike with users where you see five different options), select the one that’s presented:
- Set the Title property of the gallery to ThisItem.Name to display the name of the security role(s) assigned to the team and move up this new screen so it is the first screen within this app (the original form screen can be deleted if needed):
- Give the app a suitable name and save the app (when an app is saved for the first time, it gets published on the save). Once the add designer is closed, the App ID gets populated with the ID of this new app:
- Click on OK, Save and Publish the changes on the Teams entity main form. Navigate to a team record in the model-driven app and the embedded canvas app will display the list of security roles assigned to that team:
To summarize, you can utilize an embedded canvas app with a gallery to view a list of security roles assigned to the team in the Unified Interface using the ModelDrivenFormIntegration control. By adding a security roles list and setting the Items property (as shown below), you can have visibility into a team’s assigned security roles from within a model-driven app directly on the team record.
Have fun! Get addicted!