Salesforce Integration
CommCare supports multiple ways to integrate with Salesforce using a middleware system, enabling bi-directional data sharing between your case management system and CRM.
This hub page brings together two guides for integrating CommCare and Salesforce, depending on your team's technical capabilities and use case needs:
CommCare supports integration with Salesforce via both Microsoft Power Automate and OpenFn, and the right choice depends on your team’s needs and technical capacity.
Power Automate is ideal for teams seeking a low-code/no-code, Microsoft-friendly solution. It works well for scheduled or event-based syncs and can be quickly set up using Salesforce’s native connectors. Use Power Automate if you need a quick, user-friendly sync from Salesforce to CommCare or vice versa with minimal technical lift.
OpenFn, on the other hand, offers a developer-friendly and flexible platform that enables complex data flows between CommCare and Salesforce. Use OpenFn if your integration requires advanced logic, or support for offline workflows at scale.
SalesForce Integration via Power Automate
CommCare to SalesForce
This tutorial guides you through integrating CommCare data with Salesforce using Microsoft Power Automate. You can read more about Power Automate here: Power Automate Integration
Here’s a quick video showcasing the integration. For this walkthrough, we’ll use a sample Global Indicators application in CommCare and a corresponding custom object in Salesforce to demonstrate the process.
Prerequisites
A CommCare application with data you want to sync.
A Salesforce account with a custom object created to store the CommCare data.
A Microsoft Power Automate account.
Basic understanding of CommCare reports and Salesforce custom objects.
Step 1: Setting up your CommCare Application and Report
Create your CommCare application: Design your application to collect the necessary data. In our example, we have a "Global Indicators" application tracking monthly indicators.
Ensure data is collected: Collect data through your CommCare application. Verify that the data is being stored correctly in CommCare cases. Here’s a sample mapping of case properties to indicators being tracked:
Create a case report: In CommCare, create a case report that displays the data you want to sync with Salesforce.
This report will serve as the data source for Power Automate.
Ensure the report includes all the relevant case properties as columns.
Note the report URL, as you'll need it later.
Example: the report displays monthly indicators with column headers representing each indicator.
Step 2: Configuring your Salesforce Custom Object
Create a custom object: In your Salesforce instance, create a custom object to store the CommCare data.
In our example, we created "CommCare Global Indicator Data."
Create custom fields: Add custom fields to the object that correspond to the case properties in your CommCare report.
Ensure the field data types match the data types in CommCare.
Example: create fields for each indicator tracked in the CommCare report.
Step 3: Setting up the Power Automate Flow
Create a new flow: In Power Automate, create a new "Instant cloud flow" with a "Manually trigger a flow" trigger.
Get CommCare report data
Add an "HTTP" action.
Method: GET
URI: Enter the URL of your CommCare report. Please see instructions here for CommCare’s Report API here API Access
Headers: Add necessary headers for authentication. (Refer to the CommCare API documentation for details.)
Authorization header requires Header Name: Authorization and Value: ApiKey ‘CommCare email':’apikey'
Please see Authenticationarchived for instructions on generating API keys.
Parse the JSON data
Add a "Parse JSON" action.
Content: Select the "Body" output from the "HTTP" action.
Schema: Define the schema of the JSON data from the CommCare report.
You can use the "Generate from sample" option and paste a sample JSON response from the "HTTP" action. The easiest way to generate the schema is to run the flow without adding the Parse JSON action and copying the output of the API and pasting it as a sample after adding the action in the next iteration.
The schema should reflect the structure of your report data, including column headers and values.
Create Salesforce records
Add a "Salesforce" "Create record" action.
Object Type: Select the custom object you created in Salesforce (e.g., "CommCare Global Indicator Data").
Map fields: Map the fields in your Salesforce object to the corresponding values from the "Parse JSON" action.
You can use the dynamic content from the "Parse JSON" action to populate the Salesforce fields.
To make the mapping easier, you can copy the JSON output from the Parse JSON action into an excel file, to easily see the mapping relationship between the commcare fields and the salesforce fields.
Save and test the flow:
Save your flow.
Run the flow manually and verify that the data is being synced to Salesforce correctly.
Check your Salesforce object to confirm that the data has been created.
Step 4: Verifying the Integration
Check Salesforce: Verify that the CommCare data is successfully transferred to your Salesforce custom object.
Customize Salesforce views: Create custom views and reports in Salesforce to analyze and visualize the synced data.
Important Notes
Authentication: Ensure you have the correct authentication credentials for both CommCare and Salesforce.
Error Handling: Implement error handling in your Power Automate flow to manage potential issues.
Automation: Consider automating the flow to run on a schedule or trigger based on specific events.
API Documentation: Refer to the CommCare API documentation for detailed information on available APIs and authentication methods.
Power Automate Connectors: Consult the Power Automate Salesforce connector documentation for details on available actions and limitations.
Data Mapping: Careful data mapping is essential for accurate data transfer. Double-check your mappings to ensure data integrity.
SalesForce to CommCare
This tutorial walks you through how updates made to records in Salesforce will automatically be reflected in CommCare cases.
Here’s a video that showcases the integration
Use Case
You are transitioning from managing data in Salesforce to using CommCare for field-level tracking and follow-up. This integration ensures updates made to records in Salesforce are reflected in CommCare in near real-time.
Prerequisites
Access to Salesforce with ability to manage custom objects
A CommCare application with case management enabled
A Power Automate (Microsoft) account
A CommCare API Key
Matching identifier (id) on both sides
Replication of Salesforce Objects and Fields in CommCare
To prepare for the integration, you’ll need to replicate the relevant Salesforce object and fields in CommCare. This means creating a case type in your CommCare application that mirrors the structure of your Salesforce data — for example, capturing fields like customer name, contact information, service status, or any other data your team tracks in Salesforce. Once your CommCare application is configured, import any existing Salesforce records into CommCare as cases using the Case Import feature. Make sure to include a unique identifier, such as the Salesforce Record ID, in each case. This identifier is critical for matching records between the two systems and ensuring that updates in Salesforce sync correctly with the corresponding CommCare cases.
The unique identifier received from Salesforce should be saved as “external_id” case property in CommCare for the integration to work.
Any updates made to the Salesforce object, for example like this below will now reflect in CommCare based on the integration below.
Build Your Power Automate Flow
You can trigger the integration either on a schedule (recurrence) or based on real-time updates.
Flow Structure:
Trigger:
Recurrence → Run every 30 minutes or as needed.
Get Updated Records from Salesforce:
Use “Get Records” action.
Apply to Each Salesforce Record:
Use an Apply to each to loop through the returned Salesforce records.
Case Search in CommCare:
Send a GET request to CommCare’s Case Search API:
https://www.commcarehq.org/a/{ProjectSpace}/api/v0.5/case/?type={CaseType}&external_id=={SalesforceId}Parse the JSON Response:
Extract case_id from the response.
Submit Updated Data to CommCare:
Use an HTTP POST request:
https://www.commcarehq.org/a/{ProjectSpace}/receiver/submit/Submit the forms with XML body for the relevant form in CommCare that will update the cases. The easiest way is to copy raw XML from CommCare and add dynamic data from Power Automate to construct the XML.
Check CommCare for Updated Data
After the integration runs:
CommCare web users will see updated data in CommCare HQ.
Each updated Salesforce field will reflect in the corresponding CommCare case property. CommCare mobile users will see the same updates in their apps through the case list, case detail screens or within forms.
Users can continue follow-ups directly from CommCare using the latest synced data.
These tutorials provides a basic framework for integrating CommCare with Salesforce. You can customize and expand upon this process to meet your specific needs and requirements. Remember to consult the official documentation for both CommCare and Salesforce for the most up-to-date information.
SalesForce Integration via OpenFn
Below is a quick video demonstrating how OpenFn can be used for integrating CommCare and Salesforce. This video showcases a two way sync between the systems where form and case data in CommCare can create and update objects in Salesforce and updates in Salesforce can update case properties in CommCare.
Our partners at TechnoServe have created a helpful step-by-step guide on how to integrate CommCare with Salesforce using OpenFN. In this practical how-to resource, TechnoServe—a nonprofit dedicated to helping communities build competitive farms, businesses, and industries—walks you through setting up a two-way data sync between CommCare and Salesforce. The guide also covers how to create auto-generated IDs using concatenation, offering a clear and actionable approach to streamlining your data workflows.
Full guide here:
To read more about integrating CommCare with other tools via OpenFN, please see this page: OpenFn Integration