Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

copy records through plugin

$
0
0

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.


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>