Copying data sets in recipient lists

  • Updated

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.


Optimizely customer support 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.

Setting up processes

  1. Go to the Setup area in Salesforce.

    Image: Setup

  2. In the left menu bar, click Process Automation > Process Builder.

    Image: Open Process Generator

  3. In the My Processes window, click New.

    Image: New process

  4. In the Process Name field, enter a name for the process, such as Premium Customers.

    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

  8. Click Save.

Adding criteria and defining Apex classes

  1. Click Add object in the flowchart.

    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

  3. Under Start the process, enable when a record is created or edited.

    Image: When a data set is created or edited

  4. Click Save.
  5. Click + Add criteria.

    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

  7. Under Criteria for Executing Actions, select Conditions are met.

    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

  9. Set the Operator to Equals, the Type to Picklist, and the Value to Primary.

    Image: Define conditions

  10. Under Conditions, select the All of the conditions are met (AND) option.

    Image: All conditions have been met (AND)

  11. Click Save.
  12. Click Add action under Immediate actions in the flowchart.

    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

  14. Enter a name under Action Name, such as Add Premium Customer.

    Image: Action name

  15. Select the Upsert Recipient entry from the Apex Class drop-down list.

    Image: Select Apex class

    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

  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)

  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 and select Administration > API overviewRecipient lists.

    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)

  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

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)

  2. In the Administration (Episerver Campaign) window, click Start scheduler under Synchronization of deleted recipients.

    Image: Start synchronization

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.