When deploying a Dynamics 365 Portal, there are many use cases where you only want to show data related to the authenticated portal user. Items such as registrations, invoices and other private data should only be accessible by the appropriate user.
One method of showing data on the Portal is by using Entity Lists. One of the features of Entity Lists is to allow a filter to be configured based on the currently logged in user.
In the Entity List record, navigate to the “Filter Conditions” section and you can configure the particular Portal User Attribute or Account Attribute to use as a filter.
When this is set, only records that match that particular logged in user will be displayed.
This is great for when the records have a direct relationship to the logged in user, but what if the records are not directly related to the user but they are related through a series of entity relationships?
Let’s take an example of a portal user having the ability to view a list of Opportunities of which they have influenced in some way. In this case, we don’t have a lookup directly to the “influencer” contact but rather this is setup using Dynamics 365 Connection entity.
Here is how it would look in Dynamics 365, it shows the Contact in the Connections Associated View:
The Entity List configuration does not have the direct mechanism to filter records based on related entities. However, we can build a specific Dynamics 365 system view with related filters as a basis for our Entity List that will satisfy our requirement.
We need to setup a “dummy” contact for this purpose. I generally like to setup a contact in Dynamics 365 called “Portal Filter” but it can be named anything you want.
The next thing is to create a system view in Dynamics 365 for the particular entity you want to display.
This is pretty much Dynamics 365 configuration 101:
However, we now need to add the Filter Criteria which is the key to making the filter work on the Portal. If you have ever used Advanced Find, you know you can go deep into related layers. In this example, we are just one level deep, but I have gone down many levels to get the filter required. Filter the system view based on the point where you have your contact lookup. Filter it based on the “Portal Filter” user you created earlier. Save and publish the system view.
Now setup an Entity List using the System View you just created.
As the portal configuration expert that you are, you know you will need to setup an appropriate web page to host the entity list. I assume you know how to do this.
Now when the user navigates to the portal (not yet logged in) and views the Opportunities Influenced page, there are no results;
However, when the user logs in, they then see a list of records, this will only show the Opportunities of which their contact record is linked via the relationship with the Connections entity.
This is because the Entity List will substitute the “Portal Filter” user with the currently logged in user, making this an easy way to filter records based on relationships on the logged in user. You can use any valid Dynamics 365 entity relationship to make this work.
This is a little known feature, but can make a big difference when configuring filters views for your Dynamics 365 Portal projects.
Hope this helps!
Nick Doelman is a Microsoft Business Solutions MVP and won bronze (aka “Brown” Gold) at the recent Ontario Powerlifting Championships in the Master 1, 105kg division. (Photo credit LVD Fitness)