cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Dynamics CE Embedded Canvas App Gallery Control Filter

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

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...

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.

View solution in original post

2 REPLIES 2
Highlighted
Frequent Visitor

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.

Highlighted
Frequent Visitor

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...

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.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,734)