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.  

Overview

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. Any record can be edited or deleted later.

Configuration

After entering the 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 Object Filter for ADvendio objects Only or standard salesforce objects.

  4. In the field Select the start object to configure and select the main object to be cloned from the drop-down menu options.

  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.

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 configurable the end user gets a page to select or de-select child objects.)

    1. No Confirmation: Doesn't show any confirmation message while starting the cloning process. The cloning process starts 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. The 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. The 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 the condition not met.

    1. Clone Anyway: Clones the record.

    2. Clone With Warning: Clones the record, and creates a warning message containing the object name and record ID shown to the user.

    3. Interrupt Clone: This will not clone and interrupt the whole cloning process. An error message containing the object name and record ID is shown to the user.

    4. Skip record.

  • Select Field path and Operator from drop-down values if necessary.

  • Define Field Configuration for Object Media Campaign (a 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 the 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: This 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: This 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 by opening the newly saved cloning configuration and copying the URL out of the browser. 

    2. Lightning: The IdOfTheGenericCloneConfiguration can be found by 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.