Enable Two-way Sync with Salesforce
By: Marty Y. Chang
Tags: Salesforce, Integration, CRM, Workato

Among CRM, ERP and other systems, two-way syncs enable an organization to smoothly roll out new functionality in one system while still making use of the best features from another system. One common example is that a company trying to move its entire CRM operations from a legacy system to a new one like Salesforce may choose to lead with Salesforce CPQ as an extension of the current CRM system, supported by a two-way sync of quotes and quote line items.

This kind of integration usually supports these scenarios.

Create — Record created in one system is also created in the other

— Record created in one system is also created in the other Edit — Record edited in one system is also edited in the other

— Record edited in one system is also edited in the other Delete — Record deleted in one system is also deleted in the other. This feature is usually the elephant in the room that creates agita for the team.

To demystify the bidirectional sync and create confidence in a simple approach, read on for a hypothetical scenario and practical solution you can try for free on your own. Afterward you will gain a sense of what’s actually involved in building a two-way sync.

Hypothetical scenario

Shortly after Acme, Inc. acquired Pinnacle Corporation, Acme executives launched an initiative to integrate Pinnacle’s FinancialForce ERP instance into Acme’s existing Salesforce CRM instance. Workato is used as the iPaaS middleware, and so far the following objects have been synced smoothly.

Accounts

Opportunities (without line items)

Products

Price books

Price book entries

Quotes (without line items)

The project team is now ready to start syncing quote line items.

Story: Sync quote line items on create and edit

Acceptance criteria: Given a quote in the Pinnacle org that is already synced to the Acme org, when a new quote line item is added to the quote in the Pinnacle org, then within 5 minutes the quote line item is synced to the Acme org under the correct quote.

In the Acme org, create a Pinnacle Quote Line Item ID 18-character text field to hold the ID of the corresponding record in the other org. In the Pinnacle org, create an Acme Quote Line Item ID 18-character text field for the same purpose. Next, create a workflow rule in the Pinnacle orgthat fires when a quote line item is created or edited. The workflow rules should have a filter to skip records edited by users having the Bypass Sync Automation custom permission, assumed to be assigned to the Workato Integration user. Configure the workflow rule to send an outbound message to Workato, and put Quote Line Item ID and Acme Quote Line Item ID in the message along with any other fields to sync. Configure Workato to accept the message. If Acme Quote Line Item ID is empty, Workato should create a new record in the Acme org. If the field is populated, Workato should update the existing record in the Acme org. Configured Workato so that if a record is created in the Acme org, Workato also updates the source record in the Pinnacle org with the Acme Quote Line Item ID.

Now quote line items created and edited in the Pinnacle org will also result in a corresponding create or edit operation in the Acme org!

Story: Sync quote line items on delete

Acceptance criteria: Given a quote line item in the Pinnacle org that is already synced to the Acme org, when the quote line item is deleted, then within 5 minutes the quote line item is also deleted from the corresponding quote in the Acme org.

In the Pinnacle org, create a DML Operation Subject custom object with four fields described below. Create a Subject ID 18-character text field on DML Operation Subject. Create an Acme Subject ID 18-character text field. Create an Object API Name 80-character text field. Create a Type picklist field with “insert”, “update” and “delete” for values. Create an Apex trigger on the QuoteLineItem object that creates a DML Operation Subject record for every line item that is deleted, with the appropriate fields mapped. Create a workflow rule on the DML Operation Subject object to fire whenever a new record is created with with Object API Name “Quote” and Type “delete”. Configure the workflow rule to send an outbound message to Workato. Configure Workato to accept the message and delete the corresponding quote line item from the Acme org.

Now quote line items deleted from the Pinnacle org will also be automatically deleted from the Acme org!

More food for thought

The Bypass Sync Automation custom permission briefly mentioned above can be used as part of a standard integration pattern that includes a Sync Status global value set to control what records are synced and how. (Let us know if you’re interested in a follow-up post on this topic!)

But even with just these two simple stories delivered, you’ve got a viable solution and blueprint for syncing line items from one system to another. What do you think?