Search This Blog

Monday, December 1, 2014

Cloning Microsoft CRM Records

Hi Below is the way you can create a multiple copies of any record of any entity.
Let say I have 1 record of contact which I need to make close
// Parent Contact Record
Entity oldcontact = crmservice.Retrieve("contact", ContactId,new ColumnSet(true));

// Child Contact Record
Entity newcontact;

newcontact = oldcontact.Clone(true);

newcontact.Attributes.Remove("contactid"); // This is very important step in cloning as you have to avoid duplicate primary key error.

newcontact.Id = Guid.NewGuid(); // create new GUID for new record


And you will get a copy of parentcontact record into childcontact


No comments:

Post a Comment