Super Clone
Copy Page and Custom Button Settings
The Copy page will copy related list records from an existing object to another existing object. The page will not create a new primary object like the Clone page does. The configuration for the copy page is similar to that of the clone page where field values can be set, copied, or left empty. However, the copy page does not allow fields on the primary object to be editable.
Behavior of the Copy page changes depending on the URL parameters. When the URL only contains parameters for record id and configuration name, a lookup is presented that allows the user to select an object that the records shown on the page will be copied to. When the URL an additional parameter, called “fromid”, related list records from the referenced object are shown and copied to the record that was originally worked with.
Copy Page Examples
Option 1: Copy to Another Object
Option 2: Copy from Another Object to the Current Object
- Multiple related lists can be presented on the same page.
- Related records can be unselected/selected for copying.
- Press Copy to copy related list records, and return to the original record.
- Press Cancel to return to the original record.
Custom Button Setup
Navigate to the primary object’s area for Buttons, Links, and Actions.
- Create a new Custom Button for the object.
- Enter a Label, Name, and Description.
- Select Detail Page Button for the button to be available at the top of a page layout, or select List Button for the button to be available on a related list.
- Select the behavior for the window after the button is pressed. Display in existing window with sidebar will result in an experience most users would expect.
- Select URL for the Content Source.
- Enter the path to the copy page with URL parameters for the record id and a reference to the configuration name.
The example custom button shown below references the “superclonecopy” page. Notice that “copy” is appended to “superclone”.
URL Example Explained
Option 1: Copy to Another Object
/apex/dh_superclone__superclonecopy?rid={!Account.Id}&cfg=AcctCopyOpt1&relname=Contacts
Option 2: Copy from Another Object to the Current Object
/apex/dh_superclone__superclonecopy?rid={!Account.Id}&cfg=AcctCopyOpt2&fromid=0013000001GsLzS
- “/apex/dh_superclone__superclonecopy” This is a reference to the Visualforce page. The namespace prefix is “dh_superclone”. It is separated from the page name, “superclonecopy”, by two underscores.
- “?” indicates the start of URL parameters
- “rid={!Account.Id}” tells the copy page which record should be copied. “rid” is a URL parameter, and “{!Account.Id}” is the parameters value that represents the record’s identifier. Change “Account.Id” to reference the primary object that is being copied.
- “&” separates URL parameters
- “cfg=AcctCopyOpt1” in Option 1 is the parameter that references the name of the configuration. Change “AcctCopyOpt1” to the name your configuration.
- “fromid=0013000001GsLzS” in Option 2 tells the copy page to copy the related lists records for the account with record id “0013000001GsLzS” to the current account object.
- “relname=Contacts” is used to specify lookup relationship field for the Copy page. This is an optional parameter. By default, the page does a best guess on which child object to use, but sometimes it pick one that doesn’t work well. For example, the lookup from Task may get used, and that will show options to many different object types because it can be attached to multiple objects. It works best to pick a child object relationship that will show an appropriate label and will not show options to select different parent types. If an invalid or unavailable relationship is specified, the page will ignore the parameter.
Additional URL Parameters
- Use the URL parameter ‘saveURL2’ to redirect the page after the copy operation. This takes a URL encoded string as the parameter’s value.
- Use the URL parameter ‘retURL2’ to redirect the page after the Cancel button is clicked. This takes a URL encoded string as the parameter’s value.
- A constant of ‘[newid]’ is replaced with the new record’s Id in the ‘saveURL2’ parameter. This allows you to redirect to a new page passing the new record’s Id.
/apex/dh_superclone__superclonecopy?rid={!Opportunity.Id}&cfg=MyConfig&saveURL2=006&retURL2=%2F{!Opportunity.Id}
- The custom button URL above will redirect you to the Opportunity tab after the copy completes successfully.
/apex/dh_superclone__superclonecopy?rid={!Opportunity.Id}&cfg=MyConfig&saveURL2=%5Bnewid%5D%2Fe%3FretURL%3D%2F%5Bnewid%5D
- The custom button URL above will redirect you to the standard Opportunity edit page after the copy completes successfully.
- This string ‘%5Bnewid%5D%2Fe%3FretURL%3D%2F%5Bnewid%5D’ is the URL encoded value for this ‘[newid]/e?retURL=/[newid]’, which is what shows in the location bar when editing a record.