8.2.1 Create a Generic Clone Button for any Object

ADvendio provides the user with a hierarchy of complex objects with many fields. In order to add a new record which often is similar to existing data the user now has to tediously fill out all the fields and add all the child records. Many customers had already requested custom clone functions. To simplify this process ADvendio offers a generic and reusable "clone" function.

This function allows the user to duplicate any ADvendio object data record with a maximum of three levels of dependent child object records. Before being used the administrators have to configure the duplication process by predefining which fields need to be copied and which should be set to null. 

Please not that active Workflow Rules, Processes, as well as any standard or custom triggers, will be triggered when creating Records or setting fields through the clone process which may set values counter to those in your Generic Clone Configuration.  


To use the Generic Clone function you will have to configure Generic Clone Setup for every "new" clone button.

Navigate to the Generic Clone Configuration:

  1. Navigate to the App Launcher.
  2. Search for Generic Clone Configuration.

Create a new Configuration Setup Record

The overview of Generic Clone shows all configuration settings, which already have been set up.

To create a new Generic Clone Configuration click the button New Configuration Setup. Of course any record can be edited or deleted later.


After entering name and description select the object, you want to clone.

Enter all relevant data and select the corresponding object.

  1. Enter a Configuration Setup Name.
  2. Enter a Description.
  3. Filter for ADvendio objects or standard salesforce objects.
  4. Select the main object to be cloned.
  5. Click the button Continue.

Please always choose the start object which is highest in the hierarchy. All related objects will be selected in the next step.

Pick Related Objects and select cloning function on Fields

Attention: Only child objects from a Master-Detail relationship (e.g. Campaign Items from a Media Campaign) can be selected for the generic clone. Objects from a lookup relationship can't be cloned.

The next page has four sections:

1. Options 

  • Define the Depth of Child Object.
  • Define the Cloning confirmation. (if configureable the end user gets a page to select or de-select child objects.)
    1. No Confirmation: Doesn't show any confirmation message while starting cloning process. Cloning process start automatically as soon as the user clicks the clone button at the target record.
    2. Confirmation - Objects Not Changeable: Shows all objects being cloned in a tree structure. Users can't deselect any object in the tree. User needs to confirm the selection in order to start the actual clone process. This is the default option.
    3. Confirmation - Objects Configurable: Shows all objects being cloned in a tree structure. Users can deselect objects in the tree to exclude them from cloning. User needs to confirm the selection in order to start the actual clone process.

2a. Start and Child Objects 

  • Define Start and Child Objects which you like to be cloned by checking the appropriate checkbox(es) in front of the object names. The maximum depth of child objects is three. 

2b. Cloning Condition for Object XXX

  • Define Cloning Condition for Object Media Campaign (Media Campaign is only an example) and handle Action, if condition not met.
    1. Clone Anyway: Clones the record.
    2. Clone With Warning: Clones the record, creates a warning message containing the object name and record ID shown to the user.
    3. Interrupt Clone: Will not clone and interrupts the whole cloning process. An error message containing the object name and record ID is shown to the user.
  • Define Field Configuration for Object Media Campaign (Media Campaign with all its fields is only an example). The drop-down lists Action contains a few different actions depending on the field, field type, and permissions.
    1. Clone: Will copy the current record’s field value. This is default action.
    2. Adaptive Clone: Will set the reference / lookup adaptively. This is only for fields with a Lookup data type.
    3. Leave Empty/Default: Will null out the value, so the new record’s field will either have nothing or a default value if one is specified for the field.
    4. Set Value: Will allow field values to be specified. Reference fields will show a lookup to select a record.
    5. Clone with Prefix: Will add a text before the cloned value. This is only for fields with a String data type.
    6. Clone with Suffix: Will add a text after the cloned value. This is only for fields with a String data type.
  • Click the button Save/Cancel to save/discard the changes.

3. Repeat steps 2a. and 2b. for all objects you like to clone.

You can configure the fields for all child objects in the same way. Please click on the corresponding child objects in the list Start and Child Object and define fields and values.

Create Clone Button

To give users the possibility to use Generic Clone, the system administrator has to create a custom button.

Enter the information below to generate a custom button and use Generic Clone:

  1. Navigate to Setup > Object Manager > "Objectname" > Buttons, Links and Actions and click the button New Button or Link.

  2. Enter a Label.
  3. Enter a Name (the field Name should be filled automatically but it is possible to change the API name).
  4. Enter a Description.
  5. Select the Display Type (Detail Page Button).
  6. Select Behavior (Display in new windows) and Content Source (URL).
  7. Enter the following code into the textarea field: {!URLFOR( "/apex/ADvendio__GenericCloneProcessor", null, [id={VariableOfIdOfTheMasterRecord}, fsId={IdOfTheGenericCloneConfiguration}] ) }.
    1. Classic: The IdOfTheGenericCloneConfiguration can be found opening the newly saved cloning configuration and copying the URL out of the browser. 
    2. Lightning: The IdOfTheGenericCloneConfiguration can be found opening Feature Settings and searching for Feature Name = "GenericCloneDetailConfigurationand the Template Name as the name of the object you want to Clone. The ID is the Feature Setting Name.
  8. Click the button Save.
  9. See the following code example to configure your Generic Clone feature correctly:

      → Code Example: {!URLFOR( "/apex/ADvendio__GenericCloneProcessor", null, [id=ADvendio__MediaCampaign__c.Id, fsId="a0jw0000007HIA6AAO"] ) }

  10. Drag the new button into the page layout and the feature can be used.