Configure Customer lookup in canvas apps to show either contacts or accounts

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Happy new year to all my blog readers and this is my first blog of 2020. And how about starting with a simple one and that too on canvas apps!

So this was my customer requirement. They were designing a canvas app for their business users which was basically kind of contact management. And while designing the contact edit form, they needed to show a form similar to the below one.

Advertisements
image

important fields to consider in the above screenshot are “Parent entity” & “Is company contact”.

Parent Entity field is nothing but the Company name (parentcustomerid) field of the contact. “Is Company Contact” is a custom field of type boolean.

In short the requirement was if that if the contact is a company contact, then the Parent entity field should allow users only to select Accounts else it should allow users to select only contacts. We will basically accomplish the following.

Advertisements
  • Show account/ contact dynamically depending on business logic
  • While switching between accounts and contacts dynamically, you may face the issue where either for contact or account, the display text does not show up. We are going to resolve that too.

So we set the Items property of the combobox with the below formula.

If(IsCompanyContact.Value = true,[@Accounts].’Account Name’,[@Contacts].’Full Name’)

image

If you are not aware of [@Accounts] or [@Contacts] syntax, refer to the Microsoft Docs link to learn more about record references.

Advertisements

So far so good. So we run the application.

image

So when “Is Company Contact” is selected, Parent Entity shows up the accounts as expected (screenshot above). Trust me, that’s the easy part. The one that will throw you off is the next one.

Advertisements

When the checkbox is unchecked, it should be showing the contacts. But below is how it shows up. Basically the contacts are loading but they are showing blank without any attribute value although we have specified fullname of the contact to show up in our formula.

image

We missed a simple thing and trust me it can consume some precious time of your day. The trick is to set the “Display Fields” property of the combo box. By default it was set to name for us and that’s the reason why account was showing us.

Advertisements
image

We changed that to the below formula. And now it showed up fine.

If(IsCompanyContact.Value = true,[“name”],[“fullname”])

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

One thought on “Configure Customer lookup in canvas apps to show either contacts or accounts”

Leave a Reply