Model sync (Reverse ETL) from MongoDB to Salesforce
UI demo video
You can watch a demo video of these operations in Polytomic’s admin console here.
Code
Before getting started make sure to set your Polytomic API key as an environment variable:
This example tutorial will cover four steps:
- Connecting to MongoDB.
- Connecting to Salesforce.
- Creating a data model using the MongoDB database.
- Loading data from MongoDB into Salesforce.
1. Create a MongoDB connection
The following request will create a MongoDB connection. The configuration for each type of connection can be found at the connection configuration page.
cURL
Python
Typescript
Go
2. Create a Salesforce connection
The following request will create a Salesforce connection. The configuration for each type of connection can be found at the connection configuration page.
cURL
Python
Typescript
Go
Since Salesforce connections uses OAuth to authenticate, we’ll need to follow the link returned in the auth_url
parameter in the response.
Redirection
By default, the API expects the auth_url
to be opened in a new browser window. If you’d like to modify the redirect behavior, there is an optional redirect_url
parameter that can be added to the request body.
3. Create a MongoDB data model
cURL
Python
Typescript
Go
Enumerating model sources
For information about how to enumerate sources, see this example.
4. Create a sync from MongoDB into Salesforce using the data model
This sync maps the email field in the data model to the email field of Salesforce Contacts. It additionally maps the FirstName
and LastName
fields. The field mappings can be extended to sync additional fields.
Enumerating destination objects
To list the destination objects to sync to, use the Get Sync Target Objects endpoint.