Understanding Dynamics 365 Dataverse Lookup Columns, Customer Lookup Columns, and Custom Polymorphic Lookup Columns
In Dynamics 365 Dataverse, columns are essential building blocks that define the specific data points stored within a table.
They are crucial in organizing and managing information, allowing users to capture and utilize data effectively. In this blog, we will analyze a few different types of columns and how they can help you capture data that existing tables don't have columns for.
Additionally, we will emphasize polymorphic lookup columns and walk you through how to create them.
What are Lookup Columns in Dynamics 365 Dataverse?
Simply put, columns are a method of storing information within a record in a table. They are a "field" in your database table and can be defined as a specific data type when you create them.
Here is some more information on a couple of common types of columns:
Lookup Columns
In Dataverse, one of these data types is “lookup”. Lookup columns are used to define a relationship between two tables. For example, an Account record can have a reference to one Contact record in a lookup column called “Primary Contact”. Only a Contact record can be selected in the Primary Contact column on the Account form.
Here is an example:
Customer Lookup Columns
Dataverse provides another version of a lookup column that is defined as a data type called “Customer”. Columns with this data type are automatically configured to reference a related record from either the Account table or the Contact table. When a table has a “Customer” type column, there are two additional “lookup” type columns created automatically by the system to support the multifaceted Customer relationship.
You can see an example in the pictures below:
Understanding Custom Polymorphic Lookup Columns
Dataverse provides the ability to create a custom version of a lookup column referred to as the Custom Polymorphic lookup column. These work similarly to the Customer lookup columns that were discussed above, but they can be created and configured to include relationships with two or more tables. They are not limited to Accounts and Contacts.
Natively, developers are required to use the SDK or Web APIs to create and modify these custom types of lookup columns. Luckily, the XRMToolBox includes a tool, created by developers, called “Polymorphic Lookup Manager” that System Administrators can easily use to create and maintain these special fields.
Here are the steps to creating a Custom Polymorphic column:
- Run XRMToolBox
- Connect to the desired development environment
- Open the Polymorphic Lookup Manager tool
- Select an existing solution where the custom field will be created (The “Default Solution” is not recommended)
- Select the Referencing Table in which the field will be created
- Select “<Create new polymorphic lookup>” as the “Attribute”
- Enter the desired Lookup Display name for the new field - the Lookup Schema name will be populated by the tool
- Select the desired Referenced Tables (tables to be related), optionally using the Search feature
- Click the “Create Polymorphic Lookup” option on the menu
The tool will provide a message while the field is being created, and another when it is finished.
Here is an example of a Custom Polymorphic column:
- New column will be created in the “Account” table
- New column display name will be “Referral Source”
- New column will provide three (3) “Account” many-to-one relationships for the one-lookup field
- Accounts to Contacts
- Accounts to Knowledge Articles
- Accounts to System Users
This is how it would look on the form:
How to Delete an Existing Custom Polymorphic Column
The XRMToolBox can be used to modify or delete a custom polymorphic column. Before deleting the custom field, all dependencies will need to be removed, as is the case when deleting any field. For instance, if the field has been added to forms or views, it will need to be removed from them and the changes will need to be published before the delete can be executed.
Want to Learn More About What You Can Do in the Microsoft Dataverse?
Get in touch with our team! Stoneridge experts can help you implement and configure the Dataverse to suit your business needs.
Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.
Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.