Bind Lookup Field in Edit Form Canvas App Polymorphic lookup with Dataverse Customer Data type
Use following PowerFX.
Use a Dropdown for Customer Data Type in custom card of the form.
For the Drop Down in Items Property Use below formula to populate dynamic values.
On Items property add below code.
If(
IsType(
ThisItem.Customer,
Companies
),
Distinct(
Companies,
'Account Name'
),
Distinct(
Contacts,
'Full Name'
)
)
On Default property add below PowerFX to auto populate selected value from record.
If(
IsType(
ThisItem.Customer,
Companies
),
AsType(
ThisItem.Customer,
Companies
).'Account Name',
AsType(
ThisItem.Customer,
Contacts
).'Full Name'
)
On Custom Card Update property use below powerfx.
If(
IsType(
ThisItem.Customer,
Companies
),
LookUp(
Contacts,
'Full Name' = Dropdown1.Selected.Value
),
LookUp(
Companies,
'Account Name' = Dropdown1.Selected.Value
)
)
Hope this helps.