This illustration shows you how to associate two entities in Microsoft Dynamics CRM 2011 using the associate request against a known relationship. This example will be given in VB.NET (.NET) with the Associate message against the CRM 2011 organization service. In this example we are simply associating a contact to an account as it's parent customer using the existing "contact_customer_accounts" relationship in CRM.
In VB.NET:
Dim req As New AssociateRequest()
'Target is the entity that you are associating your entities to.
req.Target = New EntityReference("account", New Guid("063DE6F9-2E6B-E111-B3CA-1CC1DEF1B5FF"))
'RelatedEntities are the entities you are associating to your target (can be more than 1 depending on type of association)
req.RelatedEntities = New EntityReferenceCollection()
req.RelatedEntities.Add(New EntityReference("contact", New Guid("C81416E4-9089-E111-ACD4-1CC1DEF1B5FF")))
'The relationship schema name in CRM you are using to associate the entities.
'found in settings - customization - entity - relationships
req.Relationship = New Relationship("contact_customer_accounts")
Dim resp As AssociateResponse = DirectCast(service.Execute(req), AssociateResponse)
I hope this helps!
this code is working
ReplyDeleteI have add this code in VB.net Script
can you please tell me. which dll added to get AssociateRequest() class?
Wow, Great information and it is very useful for us.
ReplyDeleteCrm software development company in chennai
ReplyDeleteWonderful post and more informative!keep sharing Like this!
create a website in php
How to use PHP in a website