---
title: Copying data sets in recipient lists
slug: campaign/docs/copying-data-sets-in-recipient-lists
docTags: 
createdAt: 2026-07-20T15:45:03.823Z
---

:::hint{type="info"}
**Note**

This topic is for administrators and developers with administration access rights in Salesforce.
:::

This topic describes how to copy and synchronize Salesforce data sets of contacts, leads, and personal accounts with your Optimizely Campaign recipient lists. For this purpose, the Salesforce add-on adds two Apex classes to the Salesforce Process Builder:

- **Upsert Recipient**. Updating recipients or adding new recipients.
- **Delete Recipient**. Deleting leads, contacts, and personal accounts from an Optimizely Campaign recipient list.

## Requirements

Optimizely [customer support](docId\:ZWe1T3UPz3JW6_4mc76qV) must prepare your Optimizely Campaign recipient lists for the Salesforce synchronization. Provide information about the client in which you want to use recipient lists for the Salesforce synchronization.

## Generating processes and using Apex classes

Once customer support has prepared the desired recipient lists, set up processes in Salesforce to automatically copy contacts, leads, and personal accounts in Optimizely Campaign recipient lists. For example, you can set up processes that filter customers according to a certain status and transfer them to a corresponding recipient list, such as *new customers* in a recipient list that only contains new customers.

For contacts, leads, and personal accounts in this example, a Boolean reference field (true/false) called **Premium Customer** was created first that you will need for configuring the process. See [Creating reference fields](docId\:km7uWtu_f48IsNEACzW7z).

### Setting up processes

1. Go to the **Setup** area in Salesforce.

   ![Image: Setup](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/k2ADu6Qlo_TzbmBj0eKlY-20260720-145352.png "Image: Setup")
2. In the left menu bar, click **Process Automation** > **Process Builder**.

   ![Image: Open Process Generator](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/d2A6WLaJQAWPuuKRD5jYP-20260720-145352.png "Image: Open Process Generator")
3. In the **My Processes** window, click **New**.

   ![Image: New process](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/S0HAaNCnoNgNL7_6_YJmB-20260720-145352.png "Image: New process")
4. In the **Process Name** field, enter a name for the process, such as *Premium Customers*.

   ![Image: Process name](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/fzL4sFwHbEDxHTenO3Jz6-20260720-145352.png "Image: Process name")
5. Enter a name under **API Name**, such as *Premium\_Customers*.
6. Optional: Enter a description in the **Description** field.
7. Select **A record changes** in the **The process starts when** drop-down list.

   ![Image: A data set has been changed](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/jeSYwcg0K6QAGbcj_VwvO-20260720-145352.png "Image: A data set has been changed")
8. Click **Save**.

### Adding criteria and defining Apex classes

1. Click **Add object** in the flowchart.

   ![Image: Add object](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/uNxzECH5GKjW5yHFzBrBM-20260720-145352.png "Image: Add object")
2. In the **Choose Object and Specify When to Start the Process** window, select the entity in the **Object** drop-down list that you want to set up the process for: **Lead**, **Contact**, or **Person Account**.

   ![Image: Object drop-down list](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/_fdJT-NjzqSjBkxQKzhXm-20260720-145352.png "Image: Object drop-down list")
3. Under **Start the process**, enable **when a record is created or edited**.

   ![Image: When a data set is created or edited](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/UgG1nvHIfFYUSZ1x5wlXT-20260720-145352.png "Image: When a data set is created or edited")
4. Click **Save**.
5. Click **+ Add criteria**.

   ![Image: Add criteria](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/14vUI8EthrG04FiVoLkn1-20260720-145352.png "Image: Add criteria")
6. In the right window, enter a name for the criterion in the **Criteria Name** field, such as *Is Premium Customer*.

   ![Image: Criteria name](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/RyOxkRLEpBibmzRXMTkkn-20260720-145352.png "Image: Criteria name")
7. Under **Criteria for Executing Actions**, select **Conditions are met**.

   ![Image: Criteria for executing actions](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/uS699jb5ASblVjZTSycID-20260720-145352.png "Image: Criteria for executing actions")
8. Under **Set conditions**, select the **Premium Customer** reference field from the drop-down list under **Field** and confirm your selection.

   ![Image: Select reference field](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/Tdn-2OqYLVHnbX4rRE5vw-20260720-145352.png "Image: Select reference field")
9. Set the **Operator** to **Equals**, the **Type** to **Picklist**, and the **Value** to **Primary**.

   ![Image: Define conditions](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/6YXAr5fFICmeJjhjICY9N-20260720-145352.png "Image: Define conditions")
10. Under **Conditions**, select the **All of the conditions are met (AND)** option.

    ![Image: All conditions have been met (AND)](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/rw3qkX5vdjunn38FW-ZhG-20260720-145352.png "Image: All conditions have been met (AND)")
11. Click **Save**.
12. Click **Add action** under **Immediate actions** in the flowchart.

    ![Image: Add action](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/VvirdMUwjWmb1KBdxs_x7-20260720-145352.png "Image: Add action")
13. In the **Select and Define Action** window, select the **Apex** entry from the **Action Type** drop-down list.

    ![Image: Apex action type](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/hJFraEq6IwYt6HOMCv1jC-20260720-145352.png "Image: Apex action type")
14. Enter a name under **Action Name**, such as *Add Premium Customer*.

    ![Image: Action name](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/BQIjR0bg82yt1jl7lTXOG-20260720-145352.png "Image: Action name")
15. Select the **Upsert Recipient** entry from the **Apex Class** drop-down list.

    ![Image: Select Apex class](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/AZ1E3L0PMSCP875f_RcT5-20260720-145352.png "Image: Select Apex class")

    :::hint{type="info"}
    **Note**

    You need to configure three variables for the **Upsert Recipient** Apex class: **recipientId**, **recipientListId**, and **sfOptInId**.
    :::
16. Under **Set Apex Variables**, click **Add Row** three times.

    ![Image: Add lines](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/u4FGamNmG6j8ufW7KOwZT-20260720-145352.png "Image: Add lines")
17. In the first drop-down list under **Field**, select the **recipientId** variable and set the type to **Field Reference**. Depending on the desired entity type, select the **Lead Id**, the **Contact Id**, or the **Personal Account Id** in the **Value** field.

    ![Image: Define Apex variables (recipientId)](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/qG3UMo0UIhXeVJLfMyLYc-20260720-145352.png "Image: Define Apex variables (recipientId)")
18. In the second drop-down list under **Field**, select the **RecipientListId** variable and set the value to the ID of the Optimizely Campaign recipient list to which the *Premium Customers* are to be copied. To see the recipient list ID, open the Optimizely Campaign[ menu](docId\:PmNPgvNucBrAG5Rw8f41f) and select **Administration** > **API overview** > **Recipient lists**.

    ![Image: Define Apex variables (recipientListId)](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/GNFrL7-x8EcvJ7mSnM70M-20260720-145352.png "Image: Define Apex variables (recipientListId)")
19. In the third drop-down list under **Field**, select the **sfOptInId** variable and set the value to the Salesforce ID of the created advertising permission. The type will automatically be set to **String**; do not make any changes here.

    ![Image: Define Apex variables (sfOpotInId)](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/ToJOzFs1M0AkOT0A3d2e2-20260720-145352.png "Image: Define Apex variables (sfOpotInId)")
20. Click **Save**.

## Deleting recipients from one recipient list and adding them to another recipient List

For example, a *Premium Customer* has achieved high revenues and qualified as a *Platinum Customer*. You want to delete this customer from the premium list and add it to the platinum list.

To delete recipients from one recipient list and add them to another, set up the **Delete recipient** class (which deletes the customer from the premium list) along with the **Upsert** Apex class (which adds the customer to the platinum list). Configure the **Delete recipient** Apex class only with the **recipientId** and **recipientListId** parameters. See steps 18 and 19 in the previous section.

![Image: Apex class Delete recipient](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/0Lx5LAziNRUfVieIEg_6Z-20260720-145352.png "Image: Apex class Delete recipient")

## Enabling synchronization of deleted contacts, leads, and personal accounts

To completely delete deleted contacts, leads, and personal accounts from your recipient list in your Salesforce database as well, *do not* set up a separate process in Salesforce. The Salesforce add-on takes care of synchronizing your deleted Salesforce data sets if you enable automatic synchronization of deleted contacts, leads, and/or personal accounts. Perform the following steps:

1. Open the **Administration (Episerver Campaign)** tab.

   ![Image: Administration (Episerver Campaign)](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/i0r4QPKg5oDcPoHFCFhld-20260720-145352.png "Image: Administration (Episerver Campaign)")
2. In the **Administration (Episerver Campaign)** window, click **Start scheduler** under **Synchronization of deleted recipients**.

   ![Image: Start synchronization](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/iDFnTmfJXBZVnQ1HXIHJe-20260720-145352.png "Image: Start synchronization")

:::hint{type="info"}
**Tip**

Click **End** to interrupt the synchronization of the deleted data sets. This may be necessary, for example if the configuration is faulty, and you need to correct it.

Click **Start** under **Synchronize manually** to perform (one-time) manual data synchronization. A manual start lets you limit the period of access between Salesforce and Optimizely Campaign in the log files, thereby helping to diagnose any errors.
:::
