Hi,
CreateMultiEntityAssociation method of CrmServiceclient can be used for associating 1 : n records i.e. if we have one contact record that we want to associate with multiple opportunity record ( 1-n) then we can use that method. This way we wont have to update each individual record.
Sample Code
Uri organizationUri = new Uri("http://server/crmrog/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials;
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
CrmServiceClient crmServiceClient = new CrmServiceClient(orgProxy);
List<Guid> lstOpportunityGuid = new List<Guid>();
lstOpportunityGuid.Add(new Guid("9DDCE989-0738-E411-9878-00155D56FF56"));
lstOpportunityGuid.Add(new Guid("019E1598-0738-E411-9878-00155D56FF56"));
lstOpportunityGuid.Add(new Guid("EA393A91-0738-E411-9878-00155D56FF56"));
crmServiceClient.CreateMultiEntityAssociation("contact", new Guid("CF1FC3C0-0738-E411-9878-00155D56FF56"), "opportunity", lstOpportunityGuid, "opportunity_customer_contacts");
Hope it helps ..
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts sent to your email.
