Power Apps Portals | Entity List to Entity List with Filtering Parameter
There are times when you need to navigate from one Portal Entity List to another and filter the second one by a parameter from the first. When considering the Dataverse (formerly called the Common Data Service) and Microsoft Dynamics 365 CRM solutions (otherwise known as CE) and Power Apps Portals, it would be a common request to have one Entity List of Accounts that points to a second Entity List of Contacts of the selected Account.
There are several ways to accomplish this task, and they are the following:
- You could create a Web Page that utilizes a Web Template that retrieves the correct record via Liquid.
- You could even create a Web Page that points to an Entity Form that contains a sub grid of related records
Note: Portals in Dynamics 365 are now officially called “Power Pages“. They were previously called “Power Apps Portals”, but are often still referred to as “Dynamics 365 Portals.”
When using Web Templates, you need to either insert an entity list liquid tag or build your table from scratch. In this case, I do not want to do that. When using an Entity Form sub grid, you do not have the same level of options as an Entity List and would probably need to create some Entity Form Metadata; it is not a bad thing, but your choice depends on the overall objectives.
I have decided to use an Entity List that points to another Entity List so I can tap into the out-of-the-box Portal styling; I can also tap into other Entity List features such as Details View link, Search, and Filter conditions.
Other possibilities:
- https://docs.microsoft.com/en-us/powerapps/maker/portals/liquid/liquid-filters#entity-list-filters
- https://powerusers.microsoft.com/t5/Power-Apps-Portals/Filtering-entity-list-by-query-string-value-for-Portal-Page/td-p/605970
- https://community.dynamics.com/365/b/dynamics365apps/posts/dynamics-365-portals-liquid-templates-part-3-retrieve-data-using-fetchxml
- https://stoneridgesoftware.com/using-liquid-templates-and-fetchxml-to-retrieve-data-in-a-dynamics-365-online-portal/
Needed Components
There are not that many components to this solution, but there are a couple of critical items in order to push the parent Id from the parent Entity List to the child, and we will discover this in a few moments.
In a nutshell, here are the needed components:
- Dynamics 365 for Sales View (2)
- Entity List (2)
- Web Page (2)
- Knowledge of JavaScript (You can copy and paste the below code and change a few items)
Disclaimer
For Portal development, I still prefer to use the classic Dynamics 365 for Sales (D365 Sales) solution development along with the Portal Management app, so all my work below will reflect those tools.
In this blog, I am not addressing Entity Permissions, Web Page Access Control Rules, or Web Roles. These will assuredly come into play if you need to lock down access to data or pages, but we are focusing on the singular objective of traversing from one Entity List to another.
The following resource provided me the JavaScript code for the getParameterName function: http://shaikhd365.blogspot.com/2018/05/insert-values-of-html-control-into-crm.html
This JavaScript function retrieves the selected parameter from the current URL. I am using this to retrieve the parent record Id to limit the related or child records.
Offsite Sales D365 Sales View
Remember, Power Apps Portals, to a large extent, is a mirror reflection of D365 Sales. If you need a list on a web page in your Portal, you start with a D365 Sales view; if you need a form, you start with a D365 Sales form.
The first component we need, then, is a D365 Sales View; in this case, we are working with a custom entity named Offsite Sales. Navigate to the solution that contains the desired entity, expand the entity, select views, and select new.

Add the desired columns.

Configure the filtering; here, we are only filtering by Status.

Configure the sort order.

Save and Close. Publish all Customizations.
Offsite Sales Entity List
To expose the D365 Sales view onto the Portal, we need to create an Entity List.
Navigate to make.powerapps.com, select Apps, select your Portal Management app, select Entity Lists in the left navigation, and then select New.
Select the correct entity for Entity Name and select the correct view – the view you created above.

If you desire to have a search filter (it displays a search box above the list), check the Search Enabled checkbox.

Ignore the Entity List Web Page for Details View for now; we will come back to this.

Offsite Sales Web Page
Now we need to put the list on a component that will display it on the Portal – the Web Page.
Navigate to Web Pages in the left navigation and click New.

The important field here is the Entity List field; set it to the Entity List record you created above. If you want, you can clear your Portal cache and plugin the url to see if the list displays correctly. Inside D365 Sales, you will need records created for any to show on the Portal.
Offsite Sale Participants D365 Sales View
This, essentially, is a repeat of Offsite Sales D365 Sales View but with a different entity.
Create a new view.

Configure the columns.
IMPORTANT: Ensure that you are displaying the parent entity column. In this case, Offsite Sales (Off Site Sale Name) is a parent to the Offsite Sale Participants (Dealership). If you fail to display it, the JavaScript further down this blog will not function correctly.

Configure the filtering. Here, I ensure that the parent field must contain data.

Configure the sort order.

Offsite Sale Participants Entity List
This is, essentially, a repeat of Offsite Sales Entity List, but it is pointing to the above D365 Sales View.

Because we want the secondary list to be filtered by the parent Id, we need to add some JavaScript in the Custom JavaScript field on the Options tab on the Entity List record.

Options Custom JavaScript

What you need to change
- Change the console.group if desired.
- Change any of the console.info if desired.
- Change the JavaScript variable name (offsite_sale_id) if desired.
- Change “ebs_offsite_sale_name” to the logical name of your parent record; you can find this by navigating to the field in your solution.
- Leave getParameterByName alone.
What is this function doing? First, without this function, all Offsite Sale Participant records would show regardless of what Offsite Sale was selected on the first Entity List, and this is definitely not what we want. The function takes the Id parameter in the URL, which is the Id of the parent record and compares it to each record in the second list. If the child’s parent record Id does not match, then hide that row.
Offsite Sale Participants Web Page
This is, essentially, a duplicate Offsite Sales Web Page. Point it to the correct Entity List.

Edit Offsite Sales Entity List
To get the first list to point to the second list, we need to do one more thing. Navigate back to the first Entity List (VSA Offsite Sales), and for the Web Page for Details View field, select the Web Page (VSA Offsite Sale Participants) that uses the second Entity List and ensure “id” is entered for ID Query String Parameter Name field.

So what does this look like in action? When navigating to the Offsite Sales Entity List, we see the following:

You can see that each record has a link; this is the link pointing to the second Entity List of related or child records.
After clicking on any one of these parent links, the URL will look something like this:

Notice the id parameter? The JavaScript code grabs this and uses it to filter the list. Below are the Offsite Sale Participant records, filtered by Border Sale parent record.

This is a common need for clients, yet documentation to achieve such a result is minimal. Now you have the skills to create something similar for your Portal website. Please connect with us if you have questions about using Power Apps Portals.
41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 CRM apps. Includes interactions with Power Apps and Power Automate!