Ankita
Salesforce Integration Cheatsheet
1. Introduction to Salesforce Integration
• Definition: Integration connects Salesforce to external systems for seamless data sharing.
• Common Integration Types:
o Real-time Integration: Data is synced immediately (e.g., REST, SOAP APIs).
o Batch Integration: Data is synced periodically (e.g., ETL tools).
o Middleware-based Integration: Uses tools like MuleSoft or Informatica.
2. Key Concepts and Terminologies
• API: Application Programming Interface, a way for systems to communicate.
• Endpoints: URL for accessing Salesforce APIs.
• Authentication:
o OAuth 2.0 (Preferred).
o Username-Password.
• Web Services:
o REST API: Lightweight and JSON-based.
o SOAP API: XML-based, ideal for complex transactions.
• Data Loader: Tool for bulk data import/export.
• External Services: Declarative integration with external APIs using OpenAPI specs.
3. Salesforce Integration Tools and APIs
APIs
1. REST API:
o Ideal for lightweight integrations.
o JSON or XML payloads.
o Example: Query Account Data.
o GET /services/data/v57.0/sobjects/Account/001xx000003DGbP
Authorization: Bearer <Access_Token>
Joyful Learning
Ankita
2. SOAP API:
o XML-based; suitable for enterprise-grade integration.
o Requires WSDL file.
o Example: Create Lead:
o <soapenv:Envelope ...>
o <soapenv:Body>
o <create xmlns="urn:enterprise.soap.sforce.com">
o <sObjects>
o <type>Lead</type>
o <FirstName>John</FirstName>
o <LastName>Doe</LastName>
o </sObjects>
o </create>
o </soapenv:Body>
</soapenv:Envelope>
3. Bulk API:
o Optimized for handling large datasets.
o Operates in two modes:
▪ Bulk API 1.0 (CSV-based).
▪ Bulk API 2.0 (JSON-based).
4. Streaming API:
o Real-time notifications for data changes.
o Uses PushTopic and Platform Events.
Tools
• Postman: Testing Salesforce APIs.
• Workbench: API testing and troubleshooting.
• Data Loader: Batch data processing.
Joyful Learning
Ankita
4. Integration Design Patterns
Remote Process Invocation
• Request and Reply: Salesforce calls an external system and waits for a response.
• Fire and Forget: Salesforce calls an external system without waiting for a response.
UI Update Based on Data Changes
• Use Platform Events or Change Data Capture.
Data Synchronization
• Bidirectional sync using middleware like MuleSoft.
Data Virtualization
• Use Salesforce Connect and External Objects.
5. Security in Integrations
• OAuth 2.0:
o Grant Types: Authorization Code, Client Credentials, Refresh Token.
o Scopes: Define API access level.
• Named Credentials:
o Simplifies endpoint and credential management.
o Example Setup:
▪ URL: https://api.example.com.
▪ Authentication: OAuth 2.0.
• Shield Platform Encryption: Encrypts sensitive data.
6. Error Handling and Debugging
• Common HTTP Status Codes:
o 200 OK: Successful request.
o 401 Unauthorized: Authentication issue.
o 500 Internal Server Error: Server-side issue.
• Debugging Tools:
o Salesforce Debug Logs.
o Postman for API testing.
o Workbench for checking API responses.
Joyful Learning
Ankita
7. Best Practices
1. Governor Limits:
o API Limits: 100,000 API calls/day (Enterprise Edition).
o Bulkify operations to avoid hitting limits.
2. Data Management:
o Use External IDs for upserts.
o Avoid hard deletes; prefer soft deletes.
3. Versioning:
o Always specify API versions.
4. Monitoring:
o Set up alerts for API usage.
o Use Event Monitoring.
8. Example Scenarios
Scenario 1: Fetch Account Details via REST API
• Request:
• GET /services/data/v57.0/sobjects/Account/001xx000003DGbP
Authorization: Bearer <Access_Token>
• Response:
• {
• "Id": "001xx000003DGbP",
• "Name": "Acme Corporation",
• "Phone": "123-456-7890"
Scenario 2: Outbound Message via Workflow
• Trigger external system call on record updates.
• Configure in Workflow Rule.
• Endpoint URL required.
Joyful Learning
Ankita
9. FAQs
• What is the difference between REST and SOAP APIs?
o REST is lightweight and uses JSON; SOAP is robust and XML-based.
• How to debug integration issues?
o Use debug logs, check error codes, and validate authentication.
10. Useful Links
• Salesforce REST API Documentation
• SOAP API Developer Guide
• Integration Patterns and Practices
Joyful Learning