web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to copy record and all child records?

(0) ShareShare
ReportReport
Posted on by

Do we have a way to copy a record and all associated child records?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    BharatPremji Profile Picture
    2,485 on at

    Hi,

    I've used the following custom workflow activity to do something similar in the past:

    crm2011distributewf.codeplex.com

    Regards

    Bharat

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    You can do a plugin that retrieves the record, and within each record, retrieve all Entity Collections for the subgrids/child entities:

    // Main Code Base

    Entity parent = RetrieveParent(parentId);

    if (parent != null)

    {

      Guid newParentId = CreateParent(parent);

      EntityCollection children1 = RetrieveChildren(parent.Id);

      if (children1.Entities.Count > 0)

      {

         foreach (Entity child in children1.Entities)

         {

             Guid newChild1Id = CreateChild(child, newParentId);

         }

      }

    }

           private Guid CreateParent(Entity parent)

           {

               Entity newParent = new Entity(bgx_Parent.EntityLogicalName);

               foreach (KeyValuePair<String, Object> attribute in project.Attributes)

               {

                   string attributeName = attribute.Key;

                   object attributeValue = attribute.Value;

                   switch (attributeName.ToLower())

                   {

                       case "bgx_parentid":

                           break;

                       default:

                           newParent[attributeName] = attributeValue;

                           break;

                   }

               }

               try

               {

                   Guid parentId = service.Create(newParent);

                   return parentId;

               }

               catch (FaultException<OrganizationServiceFault> ex)

               {

                   throw new InvalidPluginExecutionException("An error occurred in the CreateParent function of the plug-in.", ex);

               }

           }

           private Guid CreateChild(Entity child, Guid parentId)

           {

               Entity newChild = new Entity("bgx_Child1");

               foreach (KeyValuePair<String, Object> attribute in child.Attributes)

               {

                   string attributeName = attribute.Key;

                   object attributeValue = attribute.Value;

                   switch (attributeName.ToLower())

                   {

                       case "bgx_parentid":

                           newChild[attributeName] = new EntityReference("bgx_parent", parentId);

                           break;

                       case "bgx_childid":

                           break;

                       default:

                           newChild[attributeName] = attributeValue;

                           break;

                   }

               }

               try

               {

                   Guid childId = service.Create(newChild);

                   return childId;

               }

               catch (FaultException<OrganizationServiceFault> ex)

               {

                   throw new InvalidPluginExecutionException("An error occurred in the CreateChildfunction of the plug-in.", ex);

               }

           }

    You can probably create a generic class for the Create Child that will apply to all child entities.

    Good luck

  • Inogic Profile Picture
    754 on at

    We have a solution Click2Clone with below features.

    • Offers the ability to clone system as well as custom entities.
    • Easy to configure with the ability to select the fields to be carried over.
    • Allowed to carry over related records from 1:N and N:N relationships.
    • Quickly clone multiple records at a time.

     You can try our product by following the below link.

     http://www.inogic.com/product/productivity-pack/click-2-clone-microsoft-dynamics-crm-records

     Hope this helps.

     

    Thanks!

  • Soma Shekar Profile Picture
    461 on at

    HI ,

    See the below link, 

    http://dynamicsobjects.com/Products/Dynamics-Clone

  • Suggested answer
    tw0sh3ds Profile Picture
    5,600 on at

    Only by custom workflow/plugin/javascript or by installing some 3rd party tools (which use the same under the hood)

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Silbert,

    we have a product Record Clone which allows 1-Click Cloning of any record

    in CRM.

    Below are some of the features :

    Ability to clone System entities as well as Custom and their related child entities

    Once cloned or copied, the newly created record pops up on the User Interface

    Ability to Clone multiple records too (making X Clones of a single record in a click)

    Can also Clone records from Workflows

    You can try our product by following the below link.

    www.work365apps.com/record-clone

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans