Super Clone Pro
Apex API Setup

Super Clone Pro’s clone and copy functionality can be run using an Apex API. Call methods in the Apex class “ScpApi” from an Apex trigger or class.

Note: To prevent an infinite loop of cloning or copying, field values that cause the clone or copy action should be altered during the process. The creation of the new cloned record can cause trigger logic to execute again on the cloned record. The recommended way to prevent this is to set new values for the fields in the configuration that cause the logic to execute.

Clone Method

The configuration name and a set of record ids are required when calling the clone method. A clone multiplier parameter will let you specify if more than one clone of each record should be created. A parameter map lets you pass in name value pairs. This is how you would emulate functionality of URL parameters like if the process were run using the Clone Visualforce page. The method returns a map of the new parent sObject by it’s record id.

  • Configuration Name — Required
  • Record Id set — Required
  • Clone Multiplier — Optional
  • Parameter Map — Optional

Clone Example

This is a basic an example of how the clone Api could be executed in a trigger. A record id set is created for Accounts that have the name “cloneme”. Then the Api method is called if the set is not empty.  Error handling is added if the clone method encounters problems when inserting the new records.

 

Copy Method

The configuration name and a map of ids required when calling the copy method. The key of the id map is the record id of the record receiving the child records. The value of the id map is the record id of the source of the child records. A parameter map lets you pass in name value pairs. This is how you would emulate functionality of URL parameters like if the process were run using the Copy Visualforce page. The method returns a map of the receiving parent sObject by it’s record id.

  • Configuration Name — Required
  • Id Map — Required
  • Parameter Map — Optional

Copy Example

This is a basic an example of how the copy Api could be executed in a class. A map of a receiving record id and source record id is populated, and then the copy API method is called. Error handling is added if the copy method encounters problems when inserting the new records.