cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anthony_Dob
Responsive Resident
Responsive Resident

N:N Intersect Table

Is there any way to find the hidden N:N intersect table name? I would need this for a custom plugin i am writing.

 

Best Regards,

Anthony

10 REPLIES 10
Anthony_Dob
Responsive Resident
Responsive Resident

I found my solution,

 

To retrieve the intersect entity table name:

  1. Select your solution
  2. Switch to classic 
  3. Navigate to Entities 
  4. Navigate to the table that has the N:N
  5. Select N:N Relationship 
  6. Navigate  to the  N:N you need
  7. At the bottom -> Relationship Entity Name 

2021-12-21 11_58_42-Solution_ TBA Model Driven - Microsoft Dynamics 365.png

 

Then i changed my code to:

 

if (context.MessageName == "Update" && context.Stage == 20)
            {
                
                targetEntity = context.InputParameters["Target"] as Entity;
                var courseID = targetEntity.Id;

                var query = new QueryExpression()
                {
                    //Set this to the entity you wish to retrieve data from
                    EntityName = "cref8_cursist",

                    //This will return us all columns for each record returned
                    ColumnSet = new ColumnSet(true),
                };

                //AddLink(RELATIONSHIP ENTITY NAME, ENTITY UNIQUE ID FROM THE ENTITIE YOU WISH TO RETRIEVE DATA FROM, ENTITY UNIQUE ID FROM THE ENTITIE YOU WISH TO RETRIEVE DATA FROM
                var link = query.AddLink("cref8_opleiding_cref8_cursist", "cref8_cursistid", "cref8_cursistid");
                link.LinkCriteria = new FilterExpression()
                {
                    //Add this to filter the Trainee records for a specified Course
                    Conditions =
                                    {
                                        new ConditionExpression("cref8_opleidingid", ConditionOperator.Equal, courseID)
                                    }
                };

                //Invoke the service with our query
                var subjectEntities = service.RetrieveMultiple(query);

                //Loop through the result
                for (var i = 0; i < subjectEntities.Entities.Count; i++)
                {
                    //Do some logic
                }
            }

 

 

This now returns me all Trainees of the Training i did the Disassociate on. Thank you for the help @bipinshan and @rampprakash .

 

Best Regards,

Anthony

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (1,605)