We are working hard to make updates to the Shop and Account Management portal.

Please note that many of these changes will roll out this Saturday, June 1st and will require downtime. We are working to ensure minimal disruption for our eOne community and really appreciate your patience as we push out these changes. Please reach out to sales@eonesolutions.com with any questions.

Back

Moving Salesforce Triggers to Production

Published: Aug 23, 2023
Post Author Written by Ethan Sorenson

Use these steps when using a Salesforce Realtime or change data source integration to move the custom Apex triggers and objects to the production environment. For this we will be using Salesforce Change Sets.

Connector Setup

  1. Navigate to Connections > and Edit your Salesforce Sandbox connector.
  2. Verify the Create Tests box is checked.

If this checkbox is left unselected the Apex test class will need to be manually created.

image

Apex Unit Tests

Before Apex code can be moved from a Sandbox environment to Production, the code needs to pass code tests. SmartConnect automatically builds the test classes, but it may be required to manually edit the tests if they fail. It is good practice to run the Unit Tests in the Sandbox first, before pushing the changes to Production.

  1. Log into the Salesforce Sandbox > Setup
  2. Search for Apex Test Execution
  3. Click Select Tests
  4. Choose the eOne_Master_Tests test class
  5. Click Run
  6. Wait for the test to complete
  7. If the test fails, correct the errors and run the test again from step 3.
image

Enable Salesforce Deployments

The Salesforce Production instance will need to allow deployments from the sandbox.

  1. Log into the Salesforce Production > Setup
  2. Search for Deployment Settings
  3. Click Edit
  4. Make sure the Allow Inbound Changes check box is checked
  5. Click Save
image

Create an Outbound Change Set

When sending customizations to a Production instance of Salesforce, all changes need to be bundled into a Change Set and pushed to the Production environment before they can be deployed.

  1. Log into the Salesforce Sandbox > Setup
  2. Search for Outbound Change Sets
  3. Click New
  4. Provide a Name for the test
  5. Click Save
image
  1. Click Add on the Change Set Components.
image
  1. Add the following Components
Component TypeNameRequired For
Apex ClasseOne_Master_Tests1All
Apex ClasseOne_SC_RTDS12Realtime
Remote SiteSmartConnect3Realtime
Apex TriggereOneCh_<mapId>__tr_I4Change Tracking
Apex TriggereOneCh_<mapId>_tr_U4Change Tracking
Apex TriggereOne_SC_RTDS1_<SFobject>_I5Realtime
Apex TriggereOne_SC_RTDS1_<SFobject>_U5Realtime
Custom ObjecteOne Realtime Data Source Master6Realtime
Custom ObjectChange <object> (.com)7Change Tracking
  1. The Apex Test class needs to be moved over for all trigger types.
  2. If using Realtime data sources, you will also bring the trigger class definition.
  3. If using Realtime data sources, you will need to bring the Remote Site setting allowing communication with the SmartConnect web service.
  4. If using Change data sources, a unique trigger will be created for each action and map combination. In the below screenshot, I have a create and update trigger on an integration named Product.
  5. If using Realtime data sources, a unique trigger will be created for each action linked to that object. If multiple integrations are linked to the data source, they will all use the same trigger.
  6. If using Realtime data sources, this object is required as it stores a list of registered integrations and their SOQL queries.
  7. If using Change data sources, a custom change tracking object will be required for each table being tracked. In the below screenshot, I am tracking changes on the Product2 object.
image-5
  1. Click View/Add Dependencies
  2. Select the dependent components that you want to deploy, and click Add to Change Set.
  3. Navigate to the bottom of the screen
  4. Click Add Profile
  5. Add a profile with access to deploy to Production
  6. Click Upload

Process an Inbound Change Set

Now that the Change Set has been pushed to the Production environment, it can be tested and deployed into the Production environment.

  1. Log into the Salesforce Production > Setup
  2. Search for Inbound Change Sets
  3. Open the Change Set you previously created in the Sandbox
  4. Click the Validate button
image
  1. Check the box for Run specific tests
  2. In the text box enter eOne_Master_Tests
image
  1. Click Validate
  2. After the validation completes, click View Results
  3. If the tests passed successfully you can open the Change Set record and click Quick Deploy
  4. The triggers and custom objects are now in the Production environment

Reregister SmartConnect integrations

The Apex triggers that are now in production need to be pointed to the correct integrations.

Log into SmartConnect

If using Realtime data sources:

  1. Open Data Sources > Realtime Triggers
    1. Open each Salesforce Realtime data source and make these changes
    1. Check the box for Production
    1. Click Validate
    1. Click Save
    1. Click Register

You will also want to make sure your linked integration is pointed to the Production target system.

image

If using a Change data source:

  1. Open Data Sources > Change Triggers > Trigger
  2. Open each Salesforce Change data source and make these changes
  3. Check the box for Production
  4. Click Validate
  5. Click Save

You will also want to make sure your linked integration is pointed to the Production target system.

image

Managing Future Changes

If changes are made to a Change based or Realtime data source after the triggers are deployed into Production it may require a new change set.

Changes not Requiring a Change Set

  • Modifications to field mappings in the integration.
  • Adding new fields to the Realtime or Change based SOQL query.
  • Enabling or disabling the Salesforce triggers.
  • Registering an additional integration to a Realtime trigger.

Changes Requiring a Change Set

Change data sources:

Any of these actions will require a new change set.

  • Creation of a new change data source tracking an Object not currently tracked.
  • Linking an additional integration to an existing change data source.
  • Add/remove change tracked fields on the data source setup.
  • Editing the triggers on a change data source integration.
    • Example: Checking the box for Track Updates when previously only Track Creates was selected.

This change set only needs to include the following components.

Component TypeNameRequired For
Apex ClasseOne_Master_Tests1All
Apex TriggereOneCh_<mapId>__tr_I2Change Tracking
Apex TriggereOneCh_<mapId>_tr_U2Change Tracking
Custom ObjectChange <object> (.com)3Change Tracking
  1. The master test class is always required.
  2. The Apex trigger is only required if it was a new tracked action or if the change tracked fields was modified.
  3. This is only required if the Salesforce object being tracked was not previously tracked.

Realtime data sources:

Any of these actions will require a new change set.

  • Creation of a new Realtime data source tracking an Object not currently tracked.
  • Add/remove change tracked fields on the data source setup.
  • Editing the triggers on a Realtime data source registration.
    • Example: Checking the box for Track Updates when previously only Track Creates was selected.

This change set only needs to include the following components.

Component TypeNameRequired For
Apex ClasseOne_Master_Tests1All
Apex TriggereOneSC_RTDS1<SFobject>_I2Realtime
Apex TriggereOneSC_RTDS1<SFobject>_U2Realtime
  1. The master test class is always required.
  2. The Apex trigger is only required if it was a newly tracked action, object or field.

Troubleshooting

If you have any other issues, please reach out to our support team at support@eonesolutions.com.

Feeling stuck? Get the support and guidance you need to help you power through any data challenge

We're on your integration team. Connect with our people and let us know how we can help you.