Associate MS CRM Records With Many-To-Many Relationship With C#

Microsoft CRM Jan 19, 2017

To associate Microsoft CRM Data Records with an many-to-many relationship you have to use the AssociateRequest, but keep in mind that some entities have special request – you’ll find them on the MSDN. For all standard entites you can use the example shown below.

The RelatedEntities property must be filled with a EntityReferenceCollection. That means that you can associate multiple records with one organization service call.

 

AssociateRequest request = new AssociateRequest
{
Target = contact,
Relationship = new Relationship([Relationshipname]),
RelatedEntities = entityrefcollection
};

this.organizationservice.Execute(request);

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.