All Collections
CRM
Salesforce
Admin setup
Enabling Real-Time Sync on Custom Objects
Enabling Real-Time Sync on Custom Objects

This step-by-step instruction will show you how to enable Mixmax Real-Time Sync on Custom Objects in Salesforce.

Updated over a week ago

Salesforce integration is available on the Mixmax Growth + Salesforce plan and above. Check out our pricing page for more information.

The Mixmax Real Time Sync (RTS) Salesforce package works by registering Salesforce Apex triggers for the standard objects that Mixmax supports out of the box: Contacts, Leads, Accounts, Opportunities, Tasks, Events, and Users (to learn more about the RTS package, please read Salesforce Real Time Sync). For this reason, additional setup is required to make the Mixmax RTS package aware of Salesforce custom objects.

Follow the instructions below to set up and deploy Apex triggers for custom objects.

Setting up Real Time Sync for custom objects is not required to sync Mixmax activity to those custom objects or to configure rules on those custom objects; syncing activity and rules will work out-of-the-box after configuring custom objects inside the Mixmax settings dashboard.

Prerequisites

  1. Ensure that your Salesforce account has system admin permissions. These permissions are required to create and deploy Apex triggers from the sandbox environment to your production environment.

  2. Ensure that your Mixmax account has the Admin profile in order to complete the next prerequisite step.

  3. Install version 2.1.0.0 (or higher) of the RTS package. A link to install the latest version of the package is available in the Integrations section of Admin Settings in the Mixmax dashboard. Version 2.1.0.0 is the first version of the package to support RTS for custom objects.

  4. Create a new Salesforce developer sandbox from your Salesforce organization; alternatively, refresh a pre-existing sandbox from Setup > Environments > Sandboxes in the Salesforce setup menu. This ensures that the latest version of the RTS package is copied over to the sandbox. Salesforce does not allow creating and deploying Apex triggers directly from a production organization.

    • Ensure that this sandbox has the Allowed Inbound Changes setting checked from Setup > Deployments in the Salesforce setup menu.

Recommended

  • It's recommended that you're familiar with creating and deploying Apex triggers to help resolve issues that might arise during the setup process. See the Apex Triggers Trailhead Module for more information.

Step 1: Create Apex triggers for custom objects in a sandbox environment

The following actions should be taken inside your Salesforce sandbox.

  1. From Setup > Object Manager in the Salesforce setup menu, search for and select the custom object that you wish to set up RTS with.

Custom object

2. Select Triggers, then click the New button to open the Apex trigger editor.

Triggers

3. In the trigger editor that appears, you will see an Apex trigger that looks something like this:

trigger <name> on [CUSTOM_OBJECT_API_NAME] (<events>) {  

}<br>

Make a note of the custom object's API name, then paste in the following:

trigger <TRIGGER_NAME> on [CUSTOM_OBJECT_API_NAME] (after insert, after update, after delete) {
new mixmax.MixmaxCustomObjectTriggerHandler().handleTrigger();
}

Replace <TRIGGER_NAME> (which can be any alphanumeric string) and [CUSTOM_OBJECT_API_NAME] (which has to be the name of the API above). For example, if you were setting up a trigger on a custom object with the API name My_Custom_Object__c, the resulting trigger would be:

trigger MixmaxCOTriggerMyCustomObject on My_Custom_Object__c (after insert, after update, after delete) {
new mixmax.MixmaxCustomObjectTriggerHandler().handleTrigger();
}
Custom Apex trigger

4. Click the Save button to save your trigger.

Step 2: Create an Apex test class for the custom object trigger

The following actions should be taken inside your Salesforce sandbox.

  1. From Setup > Apex Classes in the Salesforce setup menu, click the New button to open the Apex class editor.

Apex classes

2. In the class editor that appears, paste in the following:

@isTest private class <TEST_NAME> { 
private static testMethod void Test_<TEST_NAME> () {
[CUSTOM_OBJECT_API_NAME] c = new [CUSTOM_OBJECT_API_NAME]();
insert c;
System.assertNotEquals(null, c.id);
update c;
delete c;
}
}

Replace <TEST_NAME> (which can be any alphanumeric string) and [CUSTOM_OBJECT_API_NAME] (which has to be the custom object's API name from step 1). For example, if you were setting up a test for a trigger on a custom object with the API name My_Custom_Object__c , the resulting test would be:

@isTest private class MyCustomObjectTriggerTest {
private static testMethod void Test_MyCustomObjectTriggerTest () {
My_Custom_Object__c c = new My_Custom_Object__c();
insert c;
System.assertNotEquals(null, c.id);
update c;
delete c;
}
}<br>
Custom trigger test

3. Click the Save button to save your test class.

4. Run the test to ensure it passes by clicking the Run Test button.

Running the test

5. When the test passes, you'll see a status update in this view:

Apex test execution

Step 3: Set up a trigger deployment from the sandbox environment

The following actions should be taken from inside your Salesforce sandbox.

  1. From Setup > Environments > Change Sets > Outbound Change Sets in the Salesforce Setup menu, click the New button to create a new outbound change set, then give your change set a name and description.

Outbound change set

2. Once the change set has been created, click the Add button in the Change Set Components subsection, then select and add the Apex trigger(s) and test class(es) created and saved in Step 1.

Change set components
Adding trigger to the change set
Adding trigger test to the change set

3. Click the Upload button next to the change set you just created, select the production organization to which you wish to deploy these triggers, and then click the Upload button on the next screen.

Uploading the change set

4. If your change set was uploaded successfully, you should see a dialog informing you that your change set is ready to be deployed.

Change set uploaded successfully

Step 4: Import and deploy triggers onto your production environment

The following actions should be taken inside your Salesforce production instance.

  1. From Setup > Environments > Change Set > Inbound Change Sets in the Salesforce setup menu, select and deploy the change set uploaded in step 3.

  2. In the Deploy Change Set view, select the Default testing option.

Deploying the change set

3. You can monitor your deployment's status from Setup > Environments > Deploy > Deployment Status.

Deployment status

Misc.

  • Some Salesforce organizations require more than 75% code coverage for trigger deployments. If this is the case for your Salesforce organization, you'll need to add additional tests in step 2.

Did this answer your question?