What is a Polymorphic Lookup?
A polymorphic lookup in Dataverse allows a single field to reference multiple types of entities. Instead of separate relationships for each entity, it enables dynamic linking across different tables.
For example, the Customer field in an Opportunity record can point to either an Account or a Contact, providing flexibility in data management. Similarly, the Regarding field in activities can reference multiple record types, such as Leads or Cases.
Polymorphic lookups streamline data modelling, improve query efficiency, and support scalable applications, making them a powerful tool in Dataverse.
How to set up Polymorphic Lookup field
Let’s say we are using the built in dataverse table ‘Case’ and we need to know who this has been created for, in this scenario for my example this could be a Contact or a User. Users would be internal contacts and Contact would be our external contacts but we don’t want multiple fields to log this. Instead we can use a Polymorphic Lookup to choose either a ‘Customer’ or ‘User’.
Unlike our standard fields to create a Polymorphic Lookup we don’t need to create a lookup field in the dataverse table instead we can use XRM Toolbox which will create this for us.
Open up XRM toolbox and search for ‘Polymorphic Lookup Manager’
On
In the Polymorphic Lookup Manager first select the solution, then the table name. This will be the logical name for the table, so with my case the table I picked called ‘Case’ is actually called ‘incident’
For the attribute we now need to select a column, if we have an existing lookup we can use this. In this case no lookup has been created yet so we will select ‘<Create new polymorphic lookup>‘
Use the ‘Lookup Display name’ to give the field/ column a name which will be visible in the dataverse table.
Now in the tables, search for the two tables that need to referenced for the Polymorphic Lookup.
Then click ‘Create Polymorphic Lookup’ and the lookup will then be created.
In Dataverse now we can see that a new field has been created
Now on the form when we click search you will now see two options ‘Contacts’ and ‘Users’
We can also add records as well straight from the lookup, if we click ‘New’ on the lookup field it will ask which entity we want to create a record for:
We can view all records as usual in the advanced lookup
We can see on the left hand side, there are now two different types of records we can filter from
Limitations of Polymorphic Lookups in Dataverse
While polymorphic lookups provide flexibility in linking records across multiple entities, they come with some challenges. Querying data can be more complex, as filtering by entity type requires additional logic. Unlike standard lookups, accessing fields from the referenced record isn’t straightforward you often need functions like IsType
and AsType
in Power Apps to work with the data effectively.
Reporting can also be tricky, as some tools struggle to interpret polymorphic relationships, requiring workarounds to extract meaningful insights. Additionally, Dataverse only supports predefined polymorphic lookups like Customer and Owner, making it difficult to create fully customisable versions without additional configuration.
Despite these limitations, polymorphic lookups remain a powerful tool for dynamic data modelling, especially in CRM and activity tracking scenarios.