How To: Indicate When a Value Was Changed on a Super Clone Pro Clone Page
October 31, 2022
How To: Redirect to the Edit Lines Page After Cloning a Quote in CPQ
January 12, 2023

How To: Split Clone Into Multiple Steps by Chaining Pages

A lot of processing can occur when cloning large hierarchies of objects that contain custom Apex, workflows, process builders, and flows. One workaround is to split the cloning process into multiple steps where the primary object is cloned first, and then this is followed by copying child relationships that are processing intense. The user will need to click Save on each page to complete the full process.

There are a few drawbacks of this method. First, a user would end up with only a partially cloned hierarchy if they click cancel or exit the browser after the first step. We will hide the cancel button on some pages to reduce this possibility. Second, fields that use the action “Reference/Clone” or “Reference/Clear” reconnect lookup/master detail fields with new records that were cloned. If the referenced record is separated into a different step, the logic will not have the record information to set the field value.

Example Summary

This will show an example where the process is split into three steps. First, the primary object (Job) will be cloned using the Clone page. Then, a child relationship (Job Tasks) will be copied from the original hierarchy to the new primary object using the Copy page. Finally, the other child relationship (Job Orders) will be copied from the original hierarchy to the new primary object using the Copy page.

Each configuration will have the primary object (Job), but the child relationships will be different.


JobClone – Configuration to clone the primary object and some child objects that don’t have much logic to run.

JobTaskCopy – Configuration to copy the task child object.
JobOrderCopy – Configuration to copy the order child object.

Creating the Custom Button URL

We will break this into multiple steps to show how the URLs change as they get encoded and combined together. We will start with what the URLs would look like unencoded. The “buttonCancel=0” parameter will hide the cancel button. The “saveURL2” parameter will be the encoded URL of what page to load after the save button is pressed. The JobOrderCopy URL doesn’t have a “saveURL2” because it will redirect to the record referenced in the “rid” parameter.


First we will encode the JobOrderCopy URL. To make things easier we will replace characters !,{,},[,] with other characters. We don’t want them encoded, so the record Ids can be merged into the string as expected. For the example I’ll use three Zs(ZZZ) to mark them in the string, so I can spot them and revert them back to the bracket types required. To URL encode, I usually google an online utility. Here is one I’ve used in the past.

1) Below is the encoded string with replaced special characters.


2) We now append this as the saveURL2 parameter to the JobTaskCopy URL


3) Then replace the special characters for merge variables in the new URL with ZZZ and encode again.


4) Take this string and then set it as the saveURL2 parameter on the JobClone URL


5) Finally, fix the spots with ZZZ so the merge variables will work again.


Custom Button

Add this URL to the custom button. Add the button to a page layout, and test it out to confirm it works as expected.

Page Step Example

Below are screen shots using the very simple records and hierarchy, but they will give you an impression of what the users will walk through.

JobClone: click the clone button from the record page, and the first Clone page should display. Click Save.

JobTaskCopy: The copy page shows the original Job record, but fields are not editable because the copy page only creates the child record. Notice the Cancel button is hidden because of the URL parameter setting.

JobOrderCopy: The copy page for orders appears.
Finally after the last save, the record page for the new Job appears.

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.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
Read more