What integration patterns and best practices are recommended for connecting external ERP systems with Sales Cloud?
Answer
Basics: ERP systems own orders, invoices, inventory and pricing; Sales Cloud owns accounts, opportunities and quotes. Integration keeps them aligned. The Salesforce Architects pattern catalog names the options: Remote Process Invocation (request and reply, fire and forget), Batch Data Synchronization, Remote Call-In, UI Update Based on Data Changes, and Data Virtualization.
How it works:
- Define system of record per entity and field.
- Add an External ID field on Account/Product/Order for keying (ERP_Id__c).
- Outbound events: change data capture or platform events, consumed by middleware or a subscriber, which calls the ERP.
- Inbound updates: ERP or middleware calls REST/Bulk API with upsert by External ID.
- Real-time lookups: Apex callouts via Named Credentials, or Salesforce Connect external objects over OData.
- Observe: Event Monitoring and logging for auditing and error handling.
Advanced / deep dive: Prefer asynchronous, idempotent messages with retry and dead-letter handling. Use Bulk API 2.0 for large loads (parallel, retried by Salesforce) and Composite API to reduce call counts. Platform events and CDC have replay windows (commonly documented as 72 hours; verify for your event type) so subscribers can recover. Salesforce Connect avoids storage but depends on ERP availability and latency, and external objects have query and relationship limits and cannot do everything standard objects can. Use a middleware layer to decouple, transform and throttle. Secure with Named Credentials and External Credentials (OAuth, mutual TLS), an integration user with least privilege and IP restrictions.
Code / config example: Queueable callout using a Named Credential:
public , Database.AllowsCallouts {
List<Id> orderIds;
{ orderIds = ids; }
{
List<Order> orders = [SELECT Id, OrderNumber, TotalAmount FROM Order WHERE Id IN :orderIds];
();
req.setEndpoint();
req.setMethod();
req.setHeader(, );
req.setBody(JSON.serialize(orders));
().send(req);
(res.getStatusCode() >= ) { }
}
}