| Mohsin Ahmed

Have you ever tried using polymorphic lookup data type Dataverse (CDS) fields in Canvas Apps? If you have, then you will know that it is not as straightforward as you would expect.

In this blog, we will try to explain polymorphic complex fields and how they behave when added in a form in a Canvas application.

First things first,
What is a polymorphic complex form field?
To answer this, let’s first go over an excerpt from Microsoft’s documentation:
Microsoft Dataverse supports relationships between records. Each record in the Accounts entity has a Primary Contact lookup field to a record in the Contacts entity. The lookup can only refer to a record in Contacts and can't refer to a record in, say, the Teams entity. That last detail is important because you always know what fields will be available for the lookup. Dataverse also supports polymorphic lookups, which can refer to a record from any entity in a set. For example, the Owner field can refer to a record in the Users entity or the Teams entity. The same lookup field in different records could refer to records in different entities. In this case, you don't always know what fields will be available.

If you want to go over this document in detail, you can head over to this link: Understand record references and polymorphic lookups in canvas apps

Now let us look at how these fields look like on power apps portal. We have set up an environment with the default deployment of Dataverse. The Contact entity contains a column by the name of “Company Name” and this field has a data type of “Customer”. This column is indeed a polymorphic lookup column, which can refer to a record from either the Account entity or the Contact entity.

Power App forAll limitations

Since we now have a clear understanding of polymorphic lookup fields, so let us look at how these behave when they are added to a form in Canvas applications. For this purpose, we have set up a sample application for viewing and editing contacts.

The first screen of the application contains a list for displaying contacts.

Power App forAll limitations Issue 1

Tapping on a particular contact row will take the user to the form screen where they can view and edit details of the contact.

Power App forAll limitations Issue 2

The Edit Form control provides an easy interface to add form fields. The user can add fields of their choice to the form, most of which will work out of the box. The control easily allows adding Lookup fields to the form as well which are shown as “Complex” data type form fields. Notice that these complex form fields have a dropdown for selection instead of a text field for input, as is present on the other non-complex form fields. One such example is the “Preferred Method of Contact” field added to our sample form.

Power App forAll limitations Issue 3

Now let us add the “Company Name” field to the form and see what happens.

Power App forAll limitations Issue 4

As you can observe, upon adding the “Company Name” field to the form, the data card remains empty, and no control is present for the user to be able to view or edit the field.

Why did this happen, you may ask yourself. This happened because this column/field differs from the rest because of it being a polymorphic lookup type column. Yet, Canvas apps do not play nicely with such fields in forms and the developer will need to manually add relevant controls to the form field’s datacard. Without knowing the reason of this anomalous behavior, most developers would find themselves in a tough spot when wanting to work with polymorphic complex type fields in Canvas applications.

Now that you are fully aware of the problem and its root cause, you are ready to learn about and implment the solution to this problem.

Join us in the next blog post, where we deep-dive into working with polymorphic complex form fields in Canvas applications.

Learn more about Imperium's Power App Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.

About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.

More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting