Canvas Apps & Lookup Fields (CDS)

Canvas apps are amazing. Seriously so. I’ve been developing my knowledge around them, and it’s incredible what you’re able to do with them. Clients are loving them as well, with how quickly it’s possible to develop something that’s visually appealing.

From a licensing perspective when looking at using data into/out of D365, I’m usually using the CDS as the datasource. This means that apart from a handful of scenarios, users would be licensed with a PowerApps licence, rather than a D365 one.

With all of the wonders and benefits that canvas apps brings, there still are some limitations. One of them I came across earlier today pertains to lookup fields.

Using Contact as an example, we see that ‘Currency’ is a lookup field:

When inserting a Gallery control, it’s possible to choose up to 3 fields to be displayed (depending on the layout selected). However, when we go set the value to a lookup field from the entity, they’re not there – it’s not possible to select a lookup field to be displayed. As you can see below, there’s no possibility to select ‘Currency’ (which we saw above):

I have no idea why Microsoft chose to do this, as it is possible to select a lookup field when connecting using a D365 datasource (though admittedly even then it only seems to work in limited situations, such as for Opportunities)

So, ways to work around it:

  1. Don’t! Accept the situation for what it is, and hope that Microsoft allows it in the future
  2. Create a custom text field for the entity. Create behaviour (eg with Flow, though keep in mind scalability of the solution and Flow run limits – you don’t want to be burning through all of them!) to copy the value of the lookup field to this new field (ensure that if the value is changed, it updates the custom field value as well). You can then use this field to be shown on the gallery control
  3. For lookup fields that are actually lookups (see item 4 below), it’s possible to change the ‘Text’ property for the field. Using the example above of Currency, the formula needed would be ‘LookUp(Currencies,’Currency Name’ = ThisItem.Currency.’Currency Name’).’Currency Name” (without the extra quotation marks). See left side image below for example of this
  4. For lookup fields that are actually of type ‘Customer’ (yup – special behaviour…thanks Microsoft!) there’s a different way that you’ll need to do this. You have to use the AsType function to declare  the type (i.e. account) of the relationship (this can also work for Owner fields, where the owner can be a user or a team). The formula needed to show the Account name would be AsType(ThisItem.’Company Name’,[@Accounts]).’Account Name’. See right side image below for the example of this

I’d also like to give thanks to Jason Almeida for his help and assistance with finding solutions – he’s an amazing guy!

What are your thoughts on this?

2 thoughts on “Canvas Apps & Lookup Fields (CDS)

  1. Just had time to check my app. I’m basically trying to do the exact same, but doing it from the “event registration” (msevtmgt) entity and not from Contacts. So I’ve tried adding “.Contact.” after Thisitem in your AsType formula:
    AsType(ThisItem.Contact.’Company Name’,[@Accounts]).’Account Name’

    I’m not getting any errors, but there’s not result and I get a message saying:
    “This formula uses scope, which is presently not supported for evaluation”

    Like

    1. So the reason for this is because the example I gave using Contacts was referring to a lookup field directly on the Contact form, and bringing in a value for it. In the example you bring, the field for Company Name isn’t actually on the Event Registration form. So either you’d need to find a way to jump across multiple entities (which I don’t know how to do, or if it’s possible, at this point in time), or you could add the field to the form, auto-populate it from the contact, and then use that to resolve against Account

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s