Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Dynamics CE Embedded Canvas App Gallery Control Filter

Posted on by 3,962

I'm wondering if this is a limitation with the customeraddress entity in Dynamics CRM (CE). I have an embedded Canvas App on a form in CRM and there is a Gallery control to display "Addresses" (the customeraddress entity). My requirement is simple: I want to display addresses for a particular Contact. I can successfully get it to filter the Gallery based on a comparison between a custom field on the Addresses entity and a custom field on the form, or with hard coded values. What won't work for me is filtering based on the "Parent" attribute of Addresses. When the Gallery renders on the form, it appears to be searching but is blank and no addresses are displayed.

 

The Parent attribute is a polymorphic lookup field that can contain an entity reference to a Contact or Account. The field I am comparing it to that lives on the form is a lookup field to the Contact entity. The formula I have in place for the Items property of the Gallery control is:

 

Filter(Addresses, If(IsType('Parent', [@Contacts] ),
AsType('Parent', [@Contacts]).Contact) = ModelDrivenFormIntegration.Item.'contactlookupfieldname'.Contact)

 

The fields in the formula were chosen with Intellisense so I know that the app is aware of the form context and the available attributes on Addresses. And because I was able to get filtering to work with a different field, I think I have it narrowed down to something with the Parent attribute. This formula passes the app checker but there is a warning about Delegation. I've seen other examples of Gallery controls working even with the Delegation warning.

 

I hope this is not a limitation of embedded PowerApps. Thanks in advance for any ideas or solutions.

  • RE: Dynamics CE Embedded Canvas App Gallery Control Filter

    I solved it. I needed to retrieve the full record for the entity on the form and then retrieve the GUID of the lookup field from there.

    I set a variable like this:

    Set(varname,LookUp('form entity name', formentityprimaryidentifiername = ModelDrivenFormIntegration.Item.formentityprimaryidentifiername).contactlookupfield.contactid);

    Then I use the variable in the Filter like this:

     Filter(Addresses, If(IsType(Addresses[@'Parent'], [@Contacts] ), AsType(Addresses[@'Parent'], [@Contacts]).contactid = varname))


    I found the answer on this post: https://medium.com/hitachisolutions-braintrust/overcoming-top-5-challenges-with-embedded-canvas-apps-f5698b32a7b5

    The relevant piece was:

    1. Challenge #1: The ModelDrivenFormIntegration control does not fetch values for fields of related entities. For example, the following will not work to get the list of contacts for an account (when the control is connected to the accounts entity):

    ModelDrivenFormIntegration.Item.Contacts

     

    Trick #1: The ModelDrivenFormIntegration control should only be used to obtain the GUID of the contextual record. The CDS connector, along with Lookup, should be used to obtain the complete record.

  • RE: Dynamics CE Embedded Canvas App Gallery Control Filter

    Here's an update on this. The Parent property of the customeraddress entity is not the problem with the Gallery filter. I have it working when I hard-code a GUID for a Contact like this example:

     

    Filter(Addresses, If(IsType(Addresses[@'Parent'], [@Contacts] ),

    AsType(Addresses[@'Parent'], [@Contacts]).contactid

     = GUID("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")))

     

    The problem is when I try to retrieve the Contact GUID from a Contact lookup field on the Dynamics CE form where the Canvas App is embedded. 

     

    Filter(Addresses, If(IsType(Addresses[@'Parent'], [@Contacts] ),

    AsType(Addresses[@'Parent'], [@Contacts]).contactid

     = ModelDrivenFormIntegration.Item.'contactlookupfieldname'.contactid))

     

    I've tried many variations including trying to place the Contact GUID in a global variable and then using the variable in the Filter.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans