Hi,
I am writing a plugin to copy the related records of an entity. I was able to copy the parent record and stuck in copying related records. I've retrieved related records through query expression and I am trying to create new records(duplicates).
Here is the code snippet that is throwing error: "Cannot insert duplicate key".
if (listCaseParticipants != null)//listCaseParticipants has the retrieved entitycollection
{
foreach (Entity caseparticipants in listCaseParticipants)
{
Entity caseparticipantentity = caseparticipants;
caseparticipantentity.Attributes.Remove(caseparticipantentity.LogicalName + "id");//this line throws error.
Guid relatedCasePId = service.Create(caseparticipantentity);
}
}
How should I create new copy of each retrieved record?
Please guide me through this. Thanks for any help.
*This post is locked for comments
I have the same question (0)