Model sync from Salesforce to Netsuite
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 covers five steps:
- Connecting to Salesforce.
- Connecting to Netsuite.
- Verifying connection readiness.
- Creating a Salesforce data model.
- Create a sync from Saleforce to Netsuite that filters out Salesforce Contacts with an empty LastName field.
1. Create a Salesforce connection
The following request will create a Salesforce connection using the Create Connection endpoint (note that, as an alternative, you can also use Polytomic Connect’s embedded auth).
cURL
Python
Typescript
Go
Since Salesforce connections use 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.
2. Create a Netsuite connection
The following request will create a NetSuite connection.
cURL
Python
Typescript
Go
3. Verify that Polytomic has loaded schemas
Before using either connection for syncing, verify that the Get Schema Status call for each connection ID returns cache_status = true
(you can poll the endpoint until you see this).
When this value is set to true
, the connections’ object schemas are ready to be interrogated.
4. Create a Salesforce source data model
We will now create a data model on Salesforce. Data models are collections of fields (i.e. views) from which you can select any subset to sync to other systems.
Enumerating source objects
In this example, we will build a data model on the Salesforce Contact object. To list all Salesforce objects, call the Get Sync Source endpoint with your Salesforce connection ID.
Enumerating source object fields
You can list all fields for a particular object to see what’s available to select from in your model. You can do that by calling the Get Sync Source endpoint with your Salesforce connection ID and the query parameter params[stream_id]=${salesforce_object_name}
(for example: params[stream_id]=companies
).
Building our Salesforce model
We will now build a Polytomic source model using the Create Model endpoint.
cURL
Python
Typescript
Go
5. Create a sync from Salesforce to Netsuite using the above data model
This sync maps the email field from the Salesforce data model to the email field of Netsuite 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.
Creating a sync from Salesforce Contacts to NetSuite Contacts
We will now build a sync from Salesforce Contacts to NetSuite Contacts using the Create Sync endpoint.