Embedded Canvas Apps

Related entity fields in an embedded canvas app – Part 2

My last post highlighted that displaying related entity fields in an embedded canvas app isn't that easy or straight forward. That being said, there is a trick to make that work.

Using the same example for consistency, we want to display a related contact's (Owner Party) phone and email in a gallery of CustomEntity. The following expressions work within the app designer but display no data from within the model-driven form:

ThisItem.'Owner Party'.Email
ThisItem.'Owner Party'.'Address 1: Phone'

To make this work, create a couple of labels (one for each related entity field) with the following expressions. Set their visibility to false. Displaying email and phone using a record from the gallery of CustomEntity forces the app to fetch those fields of the related contact. This makes it possible for these fields to be displayed in the embedded canvas app even from within the model-driven form.

Expression for displaying phone:

First(BrowseGallery.AllItems).'Owner Party'.'Address 1: Phone'

Expression for displaying email:

First(BrowseGallery.AllItems).'Owner Party'.Email

Save and publish the app. Reload the model-driven form and these fields will now show values.

Related entity fields in an embedded canvas app

Note: There will be no visible change from within the app designer as the email and phone were visible earlier as well.

To summarize, if fields of a related entity are not visible from within a model-driven form, add a label per field and set the text property of the label to display the field's value of any record from the gallery of the primary entity and the visibility to false. This forces the app to "download" those values and display them from within the model-driven form.

Have fun! Get addicted!

Leave a Reply