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

Show 3rd level entity data

Hi,

 

Im trying to create an app with CDS using data from dynamics. I have an issue based on 3 entities where te relationships are like this:  EntityA 1:N EntityB N:1 EntityC

in this case, i need to place data from EntityC that corresponds to an EntityA. What i tried to do is:

Filter('EntityB', Condition that makes it match with EntityA).EntityC.data
using this kind of formula im getting blank tables, but the strange thing is that the number of blank rows returned equals the number of records that it should get.

Is there any way to achieve this?

 

Thanks!

 

Ignacio.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @Ignacio_S

Do you want to get records that depend on "Entity A" from "Entity C"?

Firstly, let me explain why this code doesn’t work.

The result of “Filter('EntityB', Condition that makes it match with EntityA)” is a table. But what we need is a collection of "Entity C" associated with each record in this table. So we need to perform the operation of referencing "Entity C" separately for each record. So it is recommended that you use the ForAll function.

Finally, I’ve made a test for your reference:

My data source:

EntityAS:

  • NameText/ Primary Field

EntityBS:

  • NameText/ Primary Field
  • EntityALookup
  • EntityCLookup

EntityCS:

  • NameText/ Primary Field

EntityAS 1:N EntityBS N:1 EntityCS

Step1:add a combo box control:

Item:

 

EntityAS

 

OnChange:                      

 

ClearCollect(Var,ForAll(
    Filter(
        EntityBS,
        Name in ComboBox1.Selected.EntityBS.Name
    ),
    EntityC
).Name)     
/* The records of the related "EntityCS" of all records that meet the conditions in "EntityBS".Because the whole table is traversed, there may be duplicate records at present. In order to remove the duplicate records, we must filter "EntityCS" again*/

 

Because my data source is used for temporary testing, there are many duplicate fields name. In order to eliminate ambiguity, I set up a custom set here to store the filtered results. Considering that you may have a similar situation, I added this step to ensure that this solution is feasible.

Step2:add a gallery control and set its item property to:

 

Filter(EntityCS,Name in Var.Name)

 

 

The gallery will display the records in "EntityCS" related to the records in "EntityAS" I selected

Best Regards,

Bof

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @Ignacio_S

Do you want to get records that depend on "Entity A" from "Entity C"?

Firstly, let me explain why this code doesn’t work.

The result of “Filter('EntityB', Condition that makes it match with EntityA)” is a table. But what we need is a collection of "Entity C" associated with each record in this table. So we need to perform the operation of referencing "Entity C" separately for each record. So it is recommended that you use the ForAll function.

Finally, I’ve made a test for your reference:

My data source:

EntityAS:

  • NameText/ Primary Field

EntityBS:

  • NameText/ Primary Field
  • EntityALookup
  • EntityCLookup

EntityCS:

  • NameText/ Primary Field

EntityAS 1:N EntityBS N:1 EntityCS

Step1:add a combo box control:

Item:

 

EntityAS

 

OnChange:                      

 

ClearCollect(Var,ForAll(
    Filter(
        EntityBS,
        Name in ComboBox1.Selected.EntityBS.Name
    ),
    EntityC
).Name)     
/* The records of the related "EntityCS" of all records that meet the conditions in "EntityBS".Because the whole table is traversed, there may be duplicate records at present. In order to remove the duplicate records, we must filter "EntityCS" again*/

 

Because my data source is used for temporary testing, there are many duplicate fields name. In order to eliminate ambiguity, I set up a custom set here to store the filtered results. Considering that you may have a similar situation, I added this step to ensure that this solution is feasible.

Step2:add a gallery control and set its item property to:

 

Filter(EntityCS,Name in Var.Name)

 

 

The gallery will display the records in "EntityCS" related to the records in "EntityAS" I selected

Best Regards,

Bof

View solution in original post

Hi,

Thanks for taking the time @v-bofeng-msft, it works. I've been stucked this past few days with this issue.

Thanks again,

Cheers!

 

Ignacio.

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (3,453)