Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to copy record and all child records?

Posted on by

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

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to copy record and all child records?

    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.

  • Suggested answer
    tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: How to copy record and all child records?

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

  • Soma Shekar Profile Picture
    Soma Shekar 461 on at
    RE: How to copy record and all child records?

    HI ,

    See the below link, 

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

  • Inogic Profile Picture
    Inogic 24,094 on at
    RE: How to copy record and all child records?

    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!

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to copy record and all child records?

    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

  • Suggested answer
    BharatPremji Profile Picture
    BharatPremji 2,485 on at
    RE: How to copy record and all child records?

    Hi,

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

    crm2011distributewf.codeplex.com

    Regards

    Bharat

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans