Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

How to Create a Polymorphic Lookup in a Model-Driven App using XRM Toolbox

Haseeb Ahmad Profile Picture Haseeb Ahmad
Introduction
Polymorphic lookups in model-driven apps enhance flexibility by allowing a single lookup field to reference multiple tables. This feature is useful for designing efficient and scalable solutions in Microsoft Dataverse. In this blog, we will walk through the step-by-step process of creating and configuring a polymorphic lookup using XRM Toolbox, making data relationships more dynamic and efficient.
What is a Polymorphic Lookup?
A polymorphic lookup is a special type of lookup field in Dataverse that can reference multiple tables instead of just one. For example, instead of having separate lookup fields for Accounts, Contacts, and Users, you can use a single polymorphic lookup to relate records from any of these tables dynamically.
Prerequisites

Before getting started, ensure you have the following:
Access to a Power Platform environment with a Dataverse database
XRM Toolbox installed on your system
Required security permissions to modify Dataverse tables


Step 1: Open XRM Toolbox and Connect to Your Environment
To begin, launch XRM Toolbox and connect it to your Dataverse environment. If you haven't installed XRM Toolbox, you can download it from the official website:
Download XRM ToolBox

Steps to Connect:
Open XRM Toolbox.
Click on "Connect" and select your Dataverse environment.
Authenticate using your Microsoft credentials to establish the connection.
Once connected, you will land on the Start Page, where you can access various tool

Step 2: Install the Polymorphic Lookup Creator Tool
  • The tool required for this process was previously called Polymorphic Lookup Manager, but it has been renamed to Polymorphic Lookup Creator. To install it:
  • Click on "Open Tool Library" from the XRM Toolbox start page.
  • In the search bar, type "Polymorphic Lookup Creator".
  • Select the tool from the list and click "Install".
  • After installation, open the tool by navigating to Tools → Polymorphic Lookup Creator.

Step 3: Identify the Target Tables
Now, it's time to determine which tables will be part of your polymorphic lookup.
Steps:
  • Click on "Solutions" in XRM Toolbox and select the solution where you want to create the lookup field.
  • Select the referencing table (the table where the lookup field will be added).
  • Select the attribute field from the attribute dropdown. If you need a new one, click on 'Create New Polymorphic Lookup
  • Enter a Display Name for the lookup field.
  • The Schema Name will be auto-generated based on the Display Name, but you can modify it if needed.
  • Choose the referenced tables (two or more) that you want to link with this lookup.
  • Click on "Create New Polymorphic Lookup" to finalize the setup.

Step 4: Review Relationships
  • After creating the lookup field, relationships with the referenced tables are automatically generated. However, it's important to verify them to ensure seamless             data interaction.
  • Steps:
  • Open the Dataverse table designer in Power Apps.
  • Locate the newly created polymorphic lookup field.
  • Review the automatically created relationships with the referenced tables.
  • Make any necessary adjustments to maintain data integrity.
  • Save and publish your changes. 


Step 5: Test the Lookup Field in a Model-Driven App
  • To verify that the polymorphic lookup is working correctly:
  • Open your Model-Driven App.
  • Navigate to the form where the lookup field is added.
  • Create a new record and check if the lookup allows you to select records from multiple referenced tables.
  • Save the record and ensure the relationships are maintained as expected.
​​​​​​​
Next Step
  • Customize its behavior using business rules or JavaScript.
  • Automate actions based on the lookup selection using Power Automate.
  • Extend its functionality with custom plugins if needed.

If you found this guide helpful, feel free to like, share, and leave a comment with your thoughts or questions. Stay tuned for more Power Platform tips!


Comments