Super Clone Pro
Copy Page Custom Button

Copy functionality will copy child relationship records, but it will not copy the primary object’s record. Child relationship records can be copied to a new parent record of the same type, back to same parent record, or to a new parent of a different type that has a relationship with the child object.

Behavior of the copy page changes depending on the URL parameters. By default, a lookup is presented that allows the user to select an object that the records will be copied to. When the “fromid” URL parameter is used, child relationship records from the “fromid” referenced object are shown, and they are copied to the record that is referenced in the “rid” URL parameter.

To get started, all you need to do is create a configuration, create a custom button, and add the custom button to a page.

Use Cases

General Custom Button Properties

  • Enter a Label and Name
  • Set “Display Type” to “Detail Page Button”
  • Set “Behavior” to “Display in existing window without sidebar or header”
  • Set URL Parameter Options

Custom Button – Prompt where child relationship records will be copied to

The confirmation page will prompt the user to select a parent record to copy the child relationship records to. A prompting field will be presented on the page using a reference of a child relationship.

Button URL

{!URLFOR('/apex/lcrm_scp__scpCopy', null, [rid=Opportunity.Id, cfg="opportunityConfig"])}

URL Parameter

  • cfg – Name given to the configuration
  • rid – Record Id of the primary object being cloned

Custom Button – Provide the Id of a parent record where child relationship records will be copied from

The confirmation page will not prompt the user to select a parent record. The record referenced in the “fromid” URL parameter will be queried, and it’s data will be presented on the confirmation page.

Button URL

The fromid parameter value can be a constant or pull in a value from a field on the object.

/* reference a hard coded record id for the fromid parameter */
{!URLFOR('/apex/lcrm_scp__scpCopy', null, [rid=Opportunity.Id, cfg="opportunityConfig", fromid="006o0000003XS1x"])}

/* reference a label value for the fromid parameter */
{!URLFOR('/apex/lcrm_scp__scpCopy', null, [rid=Opportunity.Id, cfg="opportunityConfig", fromid=$Label.Template_Opportunity_Id])}

/* reference a hierarchy custom setting for the fromid parameter */
{!URLFOR('/apex/lcrm_scp__scpCopy', null, [rid=Opportunity.Id, cfg="opportunityConfig", fromid=$Setup.Opportunity_Template__c.Record_Id__c])}

URL Parameter

  • cfg – Name given to the configuration
  • rid – Record Id of the primary object being cloned
  • fromid – Record Id where source child records will be copied from

Custom Button – Prompt where child relationship records will be copied from

The user to be prompted to choose a record to copy related lists from.

Button URL

The fromid parameter is set to the value of “prompt”.

{!URLFOR('/apex/lcrm_scp__scpCopy', null, [rid=Opportunity.Id, cfg="opportunityConfig", fromid="prompt"])}

URL Parameter

  • cfg – Name given to the configuration
  • rid – Record Id of the primary object being cloned
  • fromid – Assigning the value of “prompt” will cause the page to ask the user to select a record to copy from

Custom Button – Copy child relationship records to a Parent record of a different object type

This example will show configuration and custom button settings that will copy custom Item records from an Opportunity to a Quote. The custom Item object in this scenario will have lookup relationships to both Opportunity and Quote. This will also be incorporated into the native quote creation page, so the Super Clone Pro page to copy the records will appear after saving the Quote.

First, create a clone configuration on the Opportunity because this is where the custom Item records will be copied from.  In the Field Value Configuration section, set the action for lookup field to the Quote object as “Action Formula List“. Set the value column to “RELATIONSHIPID(clear)“.

For more information on “RELATIONSHIPID()” options see the Configuration Setup page.

The custom button first loads the native Quote creation page, and it assigns the “oppid” URL parameter the Opportunity’s record id. The “saveURL” parameter is URL encoded text, and it will redirect to the Super Clone Pro Copy page.  

/0Q0/e?retURL=%2F{!Opportunity.Id}&oppid={!Opportunity.Id}&saveURL=%2Fapex%2Flcrm_scp__scpCopy%3Fcfg%3DOpportunityItemCopy%26retURL2%3Dnewid%26rid%3Dnewid%26fromid%3D{!Opportunity.Id}

The value “%2Fapex%2Flcrm_scp__scpCopy%3Fcfg%3DOpportunityItemCopy%26retURL2%3Dnewid%26rid%3Dnewid%26fromid%3D” when decoded is “/apex/lcrm_scp__scpCopy?cfg=OpportunityItemCopy&lss=1&retURL2=newid&rid=newid&fromid=”.  Here is a break down of the encoded parameters.

  • The”cfg” URL parameter selects the “OpportunityItemCopy” configuration.
  • The “fromid” URL parameter is assigned the Opportunity record id.  
  • Salesforce appends the URL parameter “newid” when redirecting from the native record creation screen, and “rid=newid” will assign the new Quote’s record id to the Super Clone Pro “rid” parameter.
  • “retURL2=newid” tells the page to redirect to the new quote if the Cancel button is clicked.

After clicking “Copy” on the confirmation page, the user will be directed to the Quote page. They will see the copied custom Item records attached to the Quote.


URL Parameter Options

Required Parameters

  • cfg – Name given to the configuration
  • rid – Record Id of the primary object being cloned

Optional Parameters – Navigation

  • saveURL2 – This is a URL encoded string that references a custom page to navigate to after the copy operation completes.
    • By default, the parent record will be displayed after the operation that the child records were copied to.
    • Use this URL parameter to navigate to a new page that isn’t the default, like a custom Visualforce page.
  • retURL2 – This is a URL encoded string that references a custom page to navigate to after the cancel button is pressed.

Optional Parameters – Display

  • buttonSave – Set the label of the Save button, or hide the Save button by setting the parameter to 0
    • Custom Label Example: &buttonSave=Create Renewal
    • Hide Button Example: &buttonSave=0
  • buttonCancel – Set the label of the Cancel button, or hide the Cancel button by setting the parameter to 0
    • Custom Label Example: &buttonCancel=Return
    • Hide Button Example: &buttonCancel=0
  • displayrid – Add ‘displayrid=1’ to the URL, and this will cause the page to display data from the record referenced by the ‘rid’ parameter at the top of the page instead of data from the record that is being copied from.
  • lss – Turn off application of Lightning Style Sheets on the Visualforce by setting the value to 0
    • Example: &lss=0
  • pricolumns – Specify a number of columns to display for the primary object.
    • Valid values include 1 to 8 columns
  • rowsperpage – Paginate rows on all levels of the hierarchy when the number of records exceed this value
  • rowsperpagel2 – Paginate rows on the 2nd level of the hierarchy when the number of records exceed this value
  • rowsperpagel3 – Paginate rows on the 3nd level of the hierarchy when the number of records exceed this value
  • rowsperpagel4 – Paginate rows on the 4nd level of the hierarchy when the number of records exceed this value
  • rowsperpagel5 – Paginate rows on the 5nd level of the hierarchy when the number of records exceed this value
  • rowsperpagel6 – Paginate rows on the 6nd level of the hierarchy when the number of records exceed this value

Optional Parameters – Processing Behavior

  • activeteam – Filter AccountTeamMember, OpportunityTeamMember, and CaseTeamMember relationships, so only active users are included when cloning. This prevents the ‘Owner or User is Inactive’ exception.
    • Example: &activeteam=1
  • assignmentrules – Allow assignment rules to run for Cases, Leads, and Topics.
    • Example: &assignmentrules=1
  • debugrollback – Rollback the transaction to prevent the records from committing to the database
    • Example: &debugrollback=1
  • fromid – A record Id. If present, child records from this record will be copied to the record referenced in the “rid” parameter.
    • Set ‘fromid=prompt’ for the user to be prompted to choose a record to copy related lists from.
  • relname – A child relationship name used to select a lookup field. The field for this relationship on the child relationship will be used to prompt the user to select a record to copy to.
    • This only valid when “fromid” is not specified.
    • It is only needed to make the lookup field more intuitive when the default field that prompts the user to select a copy to record doesn’t have a helpful label or is valid for multiple objects (like ParentId on Task).

Additional Information