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?

16 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

  1. Thanks Nick. I have a similar scenario, however, the contact field is tied to several levels down in the relationship. I was able to construct a view in Dynamics and have tied the contact to Dummy record as described in your blog. However, the filter isn’t being applied. The full list shows up. Wondering if your technique only works with Connections or is it generic.

    Like

      1. It works for me as well. Actually, my test contact had access to much more records than I thought:)
        Your solution works perfectly. This is great stuff. Thanks Nick.

        Like

  2. Hi Nick…Thanks for the post… I have a question what if instead of a dummy contact record I want to set up a currently logged-in user…Could you tell me how to apply the filter for that on the views…

    Like

    1. There are 2 ways. In the actual Entity List record in the Portal Management App, on the general tab, scroll down to find a section called “Filter Conditions” and you can filter based on the currently logged in user. The other way is to configure Entity permissions with a scope of contact for that particular entity. I hope that helps! Cheers, Nick

      Like

  3. Hi
    I’m trying your idea but its not working for me (and I’m new in creating portals)
    what I want to do:
    I have a project entity, an account is connected to 1 project
    the project has the sharepoint document option enabled.

    in the portal I want to display all the documents from the project for the company associated to the logged user.
    so…
    I created a view in the sharepoint document table where I setup the dummy filter

    contact (dummy filter here) > account > project < sharepoint documents

    the message is:
    there is no record to display.

    I setup the filter condition to any possible option, not working
    I played with the entity permission too, without any success

    where can I find some documentation on the setup of entities which can help me?

    thanks.

    Like

Leave a comment