Understanding the 4 MuleSoft and Salesforce Integration Approaches
Salesforce alone is a powerful tool. It’s powering your customer relationships, sales pipeline, customer information, renewals, even your contracts and marketing. Integrating with your other systems — like your ERP or your e-commerce application — amplifies that power.
How you integrate with Salesforce is a bigger question than if you should. And the answer to how is based on the business need for the data involved.
If you are familiar with MuleSoft Anypoint Studio and the Salesforce Connector, you’re halfway to developing your connection between Salesforce and anything else. With your Salesforce Connector credentials in hand and the triggers in place, the next step is to choose one of the four most common ways to use MuleSoft for integrating SFDC.
The 4 Most Common Salesforce Integration Approaches Using MuleSoft
Basic Salesforce Query (SOQL)
For when the timing is not critical.
A Salesforce Object basic query, also known as a SOQL query, is one of the simplest ways to connect Salesforce with an external database, application, or API with MuleSoft. Once Salesforce authentication is configured within MuleSoft, you place a Salesforce Connector into your flow, with the SOQL query inside the Connector. The query must return a list of Salesforce Objects.
This method is optimal when you anticipate a small number of results to the query, and the results don’t need to be timely.
Example use case: If you require updated data from Salesforce for a daily report and don’t typically see a significant number of results returned, the basic Salesforce Query is enough and is simple to implement.
Bulk Salesforce Query
When working with a large number of records.
Batch or Bulk Salesforce Query is a very common method when updating or inserting data into an external database. While it needs more code than the SOQL method, it’s the ideal choice if you have a large number of records involved in your updates, but still don’t need rapid or near real-time responsiveness to changes.
There are several steps required to set up a bulk query integration:
- Create a batch flow: Using a process like Primary Key Chunking (PK Chunking), create your flow. Using chunking is more efficient since your data will be broken out into sizable but more manageable pieces. In this stage, you’ll get your bulk job ID from Salesforce that you’ll need for the remainder of the query.
- Create the batch flow query: Define the data you want to be returned from your batch flow, using the job ID from the previous step.
- Receive job status: Return the status of the job, either success or failure before doing anything with the data.
When the job completes, you can then apply the data as needed — for example, you can write them into a file or a database table.
Example use case: If you have large batches of data that need to be written out each night, such as customer data that is written to a file for a nightly SFTP process.
This method does have some restrictions you should be aware of, however. You’re limited in the amount of data returned - it must be less than 1 GB. You are only allowed 15 attempts every 10 minutes, with a two-minute query processing limit. Also, because bulk API data is asynchronous by nature, you won’t receive the results immediately.
Near Real-Time Notification Triggers
For when you need to be notified of a Salesforce record change as soon as it happens.
Relatively new to the Salesforce Connector are the near real-time notification triggers. These are built into the Connector and can check for the trigger without custom coding via a push notification.
The new triggers include:
- On New Object: Triggered when a new record is created, such as a new lead, a new account, or a new opportunity.
- On Modified Object: Returns an updated record when triggered.
- On Deleted Object: Returns any record moved to the recycle bin in Salesforce.
Example use case: Whenever a new lead is added to Salesforce from a website form, a notification is triggered to update information in an external database or target application.
When you want to kick off a MuleSoft flow based on a Salesforce event occurring.
Platform Events are the closest to real-time updates of the four methods, but are also the most involved approach. Unlike the previous method, platform events don’t just notify you that something has happened, it actually kicks off a MuleSoft flow for near real-time APIs, databases, file shares, messaging, and so on.
The trade-off with the complexity of this method is how quickly actions can take place, the ability to custom define the event and the fact that the use of event-driven architecture makes this a highly scalable solution.
Accordingly, there are more steps to implement this method than the previous ones:
- In MuleSoft, subscribe the Salesforce Connector to a streaming channel and use long polling to listen for the incoming platform event. Once the event is received, MuleSoft will kick off the designated flow(s).
- Any logic needed to transform the incoming event data from Salesforce into the MuleSoft flow is performed here.
- MuleSoft will then perform the desired operation (create, update, delete, etc.) on the specified target object. As a best practice, you should return a success or failure status from the database, API, or file share.
- Once the target operation has been completed, MuleSoft can update the Salesforce event with a success or failure status. Using the Connector, update the appropriate Salesforce Object with the success status, timestamp, error message, message id, or other data you’ve defined as relevant in this callback to Salesforce.
- The Salesforce record will then receive the status update and populate the related fields with that data.
- The Salesforce Platform Event ends, and the MuleSoft stream resumes listening for any further events.
Example use case: If Salesforce is used as the system of record for customer data, an important change like an address update may need to be shared in near real-time with other systems like e-commerce applications and shipping databases.
Big Compass is a MuleSoft partner and can help your organization determine the right approach to SFDC integration. Our Assessment, Strategy, Design, and Development service may be exactly what you need.