A new knowledge base article has been published on our support portal
Overview
In this article we will examine a solution we created for a customer who wanted to do a linked entity in an AddPrefilterLookup. Out of the box Microsoft Dynamics 365 does not support linked entities when prefiltering a lookup.
The customer scenario was that they have multiple accounts for various companies, for example Microsoft in Ireland, Microsoft in France etc, so when they are creating an Opportunity they must specify the country first, and then this will execute AddPrefilterlookup so that only Accounts in that country can be selected.
To do this, when the country is selected, we will execute the prefilter by searching for Accounts where the primary contact is in the same country.
North52 BPA Solution
The North52 BPA solution works like this:
- A Formula is set up to run in the OnLoad event of the form and the OnChange of the Opportunity Country field
- Checks if the Opportunity Country contains data
- If yes, it runs a FetchXML query to gather all relevant accounts
- Builds up the FetchXML including the returned account ID’s
- Applies that FetchXML into the the AddPreFilterLookup() function on the Parent Account field
- If no, removes the AddPreFilterLookup() from the Parent Account field
- Checks if the Opportunity Country contains data