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:
Is there any way to achieve this?
Thanks!
Ignacio.
Solved! Go to Solution.
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:
EntityBS:
EntityCS:
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 it’s 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
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:
EntityBS:
EntityCS:
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 it’s 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
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.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
201 | |
183 | |
76 | |
46 | |
37 |
User | Count |
---|---|
327 | |
260 | |
123 | |
72 | |
58 |