Problem : within Embedded Canvas app we know how to get text field values but how to retrieve the (polymorphic) Lookup values.
Before me jotting down the solution, I would like to elaborate what is Polymorphic lookup?
Polymorphic Lookups are the lookups which can refer to a record from any entity in a set. Owner field in any entity is a classic example which refers to both User and Teams entities.
Why is it important to know if it is polymorphic lookup or not to retrieve the lookup value in embedded canvas app?
Well, because if the lookup refers to more than one entity then the name (schema) of the fields which we want to retrieve varies by entity. In above mentioned Owner example, if we want to retrieve name value from the Owner field. In Teams entity Name field is called as Team Name, whereas in User entity Name field is called as Full Name.
Powerapp doesn’t know which entity Name value we want to retrieve, so we have to be specific in this case.
In Contact entity if we want to retrieve Company Name field value and display in a canvas app. Company name refers to both Contacts and Accounts entity. So in our formulae we have to be specific about which entity values are we interested in.
Following formulae retrieves Name field from Company Name Lookup by checking the condition.
If Entity type is Accounts then it retrieves Account Name, if Entity type is Contacts then it retrieves Full Name field.
If(IsType( [@ModelDrivenFormIntegration].Item.’Company Name’, [@Accounts] ),
AsType([@ModelDrivenFormIntegration].Item.’Company Name’, [@Accounts] ).’Account Name’,
AsType( [@ModelDrivenFormIntegration].Item.’Company Name’, [@Contacts] ).’Full Name’ )
Pavan Kumar Garlapati