How To: Clone an Opportunity with Quote and Quote Line Items in Salesforce
April 2, 2017
How To: Filter Records in Related Lists With Super Clone Pro
December 16, 2017

How To: Clone a Parent Object and Move Child Records to the New Parent Object

This post will show you how to clone a record and move child records from the original record to the new cloned record. To do this we use a combination of  Super Clone Pro and Process Builder. Two very simple objects will be used in this example to illustrate the concept. However, this can be applied to any two objects that have a lookup relationship or master-detail relationship that can be reparented.

 

Objects/Fields

  • This is the Parent object in the relationship. Two lookup fields were created on the Parent Object to keep track of Ids during the processing.
  • First, the Original_Parent_Object__c will be filled in by Super Clone Pro when it inserts the cloned record.
  • Second, the Move_To_Parent_Object__c will be used to tell the Process Builder how to reparent the child records.

  • This is the Child object in the relationship. It has a Master-Detail relationship to the Parent object. This process would work the same way if this were a Lookup relationship.

  • Master-Detail relationship can’t be reparented by default. You may need to update the Master-Detail field on the Child object, so that it can be updated to point at a new Parent record.

 

Process Builder

  • Create a Process Builder flow over the Parent object. Set it to start when the record changes.

  • Select the option for the flow to run when a record is created or edited.

  • Create a condition that will run when the new cloned record is inserted.
  • Use a formula to specify only new, and when the Original Parent object lookup field has a value.

  • Create an ‘Update Records’ action
  • Select the option ‘Select a record related to the Parent_Object__c’, and find the Original Parent Object
  • Set the field to be updated as the Move To Parent Object lookup field, and specify the new record’s Id

  • Create a condition that will run the Original record’s Move To Parent Object is changed.

  • Create an ‘Update Records’ action.
  • Select the option ‘Select a record related to the Parent_Object__c’, and find the Child Object’s relationship name. This will cause all records in that child relationship to be updated.
  • Set the field to be updated as the relationship field to the Parent object, and specify the value in the Move To Parent object lookup field.
  • Set the ‘Specify What Happens After Evaluating This Criteria’ as ‘EVALUATE THE NEXT CRITERIA’.

  • Create a condition that will run the Original record’s Move To Parent Object is changed.  This is the exact same condition as before.  This was done to ensure the next update of the Move To Parent object field was performed after the update of the Child records.

  • Create an ‘Update Records’ action.
  • Select the option ‘Select the Parent_Object__c record that started your process’.
  • Set the field to be updated as the relationship field to the Move To Parent object, and specify the a formula with value of ‘null’. This will clear out the value to prevent it from running unexpectedly at a later time.

  • Activate the Process Builder flow.

 

Super Clone Pro – Clone Configuration

  • Create a Clone Configuration on the Parent object
  • For the Move To Parent object field, set the Action to Leave Empty.
  • For the Original Parent object field, set the Action to Action Formula List. Then specify ‘FIELD(ID)’ in the value column.

 

Done

  • Add a custom button for Super Clone Pro.
  • Try it out.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.