Monday, July 8, 2013

MS CRM 2011 - Manage the parent customer field of a contact


The following code set the paterent customer in contact entity. I was unable to find any documentation of this, I hope this will be helpful for you.
// Comment

//for contact entity
EntityReference myRef = null;
myRef= new EntityReference("contact", (Guid)myContact.ContactID); 
if (myRef != null) contactEntity["parentcustomerid"] = myRef; 
// Commit entity to CRMGuid 
Guid result = service.Create(contactEntity);

//for account entity
EntityReference myRef = null;
myRef= new EntityReference("account", (Guid)myContact.AccountID); 
if (myRef != null) contactEntity["parentcustomerid"] = myRef; 
// Commit entity to CRMGuid 
Guid result = service.Create(contactEntity);




Thanks 
Nicola Grillo