Filter a Dynamics 365 Portal Entity List

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.

1.filteruser

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?

2.filteruser

One might jump to the conclusion that a complex Liquid Template with embedded JavaScript and long FetchXML queries are the answer.  However, there is a relatively obscure feature of Portals that makes this easy to achieve.

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:

3.filteruser

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.

4.filteruser
Dummy Contact

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:

5.filteruser
Create System View for Entity List

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.

6.filteruser
Filter Criteria of the View

Now setup an Entity List using the System View you just created.

7.filteruser

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;

8.filteruser

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.

9.filteruser

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)

LVD_9892_preview
How much do you bench?

4 thoughts on “Filter a Dynamics 365 Portal Entity List

    1. Yes, you may need to enable entity permissions and check that your entity views are enabled for entity permissions as well. This likely is not your issue, but the other day I had duplicate contacts and was logged in with the duplicate, not main contact and was banging my head of why I couldn’t view related records.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s