Embedded Canvas Apps

Challenge #8: Lookup fields on related records

Challenge #8

There can be situations in which we want to use fields of lookup fields on related records. For example, for an account, you might want to show a gallery of related contacts. We may want to allow searching the list of related contacts by, say, the name of the user who created the record. The following formula should work.

SortByColumns(Search(AddColumns([@ModelDrivenFormIntegration].Item.Contacts, "CreatedByName",'Created By'.'Full Name') , TextSearchBox1.Text, "CreatedByName"), "fullname", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

The 'Created By' for the records is my user "Hardit Bhatia" but when I start typing in my name, no records show up.

Lookup fields on related records as is (click to enlarge)

Trick #8

For columns like the one described above (that are blank), add a label inside the gallery that forces the app to download that data. For example, add a label in the gallery with the following formula to make the search by the full name of the user who created the records work (hide the label if that is not a piece of information you want to display).

ThisItem.'Created By'.'Full Name'

I have kept the label visible so we can see how the search functionality works perfectly fine now.

Lookup fields of related records with labels (click to enlarge)

Have fun! Get addicted!

1 thought on “Challenge #8: Lookup fields on related records”

Leave a Reply