Access Entity Based On N:N Relationship For Dynamics 365 Portal

This article is about handling Dynamics 365 Portals permissions based on the N:N relationship.

Introduction

In this article, we are going to discuss how we can configure Dynamics 365 portal Web Roles and entity permission to access the entity data based on the system's N:N relationship. We are using Dynamics 365 trial and provisioned portal trial. Please refer to my earlier article for setting up Dynamics 365 trial if you want to set up a Dynamics 365 trial. Also, you can refer to this KB to provision the portal in your trial.
 
Requirement

Let’s say we have setup following custom N:N relationship between Account and Contact, so that multiple partner contacts can be associated to partner account and similarly partner account can be connected to multiple partner contacts.
 
Access Entity based on N:N relationship for Dynamics 365 Portal 

Now, we need to configure the entity permission so that the current portal user (partner contact) can access all the associated partner accounts where he is either primary contact or a partner contact.

Solution

We can create a new web role or can use an existing web role to set entity permissions. Let’s create a new web role, navigate to Portal->Web Roles and Click on New.

Let’s use “Partner Portal User” under the name field and select your portal website, keep other fields as default and hit Save.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Once it is saved, click on the V sign next to Partner Portal User web role and select entity permissions.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Click on the New button to add entity permissions.
 
Access Entity based on N:N relationship for Dynamics 365 Portal 
 
Fill entity permission form like following and click on Save and Close, here we are using Contact scope and selecting our N:N relationship under Contact relationship.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Similarly, we can set up another entity permission to allow access partner account based on the primary contact relationship like the following.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Now, let’s say we have added a portal user, Please refer our earlier article to add a quick portal user. Once contact is added we need to assign our web role to this portal user. Open Contact and click on the V sign and select Web Roles. Add your portal user web role by clicking on it.
 
Add Existing Web Role
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Add this Contact to an existing account as a primary contact or create a new account and set this contact as the primary contact. Now, when we navigate to the portal with this new contact, we will be able to see one Account based on the primary contact relationship like the following.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
Let’s go back to Dynamics 365 CE and open any Existing Account, let say Adventure Works associate current portal user to this account using N:N relationship. Now when we will go back to the portal, we should be able to see two Customers like the following.
 
Access Entity based on N:N relationship for Dynamics 365 Portal
 
So this way we can configure entity permissions for 1:N and N:N relationship for Portal. Stay tuned for more Dynamics 365 Contents !!