0
votes

Entity1 & Entity2 has an N:N Relationship
Entity2 & Entity3 has an N:N Relationship

On Entity1 Form are two subgrids

Subgrid1 - For Entity2 records
Subgrid2 - For Entity3 records

If I add/select (using the plus +) a Entity2 record from Subgrid1 all the Entity3 related records should load into Subgrid2.

I have read about Associate and using a plugin to work on this but I am only able to get the relationship between Entity1 and Entity2.

1
I am thinking of using fetchxml to populate the second subgrid. Would you be able to point me to a good example online on how to implement this? I have been searching online and all I could find are javacript codes. I am trying to implement the solution using C# plugin. - user2050472

1 Answers

0
votes

Assume Entity1 as Student, Entity2 as Subject, Entity3 as Exam.

(A) N students can enroll into N subjects
(B) N subjects can have N exams
(C) N students will write N exams

(D) Apart from these, there should be a 1:N relationship between Entity2 & Entity3. ie to configure all the related exams to subjects.

Create 3rd N:N relationship between student & exam. ie Entity1 and Entity3. I would create manual N:N relationship rather than native N:N.

Register a plugin on Associate of Entity2 with Entity1, implement the logic to retrieve all the Entity3 records for Entity2 [from (D)] and associate to Entity1.

Use the subgrids of relationships (A) & (C) in form.

Edit:

Read this to build fetchxml query, format it & execute to get EntityCollection.

service.RetrieveMultiple(new FetchExpression(fetchXmlString));