
Setup Heroku Connect Mapping to Salesforce Custom Objects
Heroku Connect makes it easy for you to build Heroku apps that share data with your Salesforce deployment. Using bi-directional synchronization between Salesforce and Heroku Postgres, Heroku Connect unifies the data in your Postgres database with the contacts, accounts and other custom objects in the Salesforce database. https://www.heroku.com/connect
Before we begin make sure you have heroku and salesforce account. Both services offer free trial. For salesforce, you have the option to use a sandbox environment.
Setup Salesforce Custom Object
Goto setup, create, objects and select new custom object. Enter object label, fill up the rest of the form and click save. Locate the Custom Fields & Relationships and click new.

Select data type and click next. Set Field Label, Length and Field Name. If you want to create an Upsert field or an external id, it’s important to check the Unique option and check External ID (this is required later when we setup the mapping). Click next and save.

Create some record.


Setup Heroku Connect Mapping
Make sure you already have heroku project created. Install these addons: Heroku Postgres and Heroku Connect.
Select Heroku Connect addon to configure. In first setup, you will see Setup Connection button, click it. Set schema name, and select the postgres db you just created. Select the correct saleforce environment (production or sandbox) and click Authorize. It will redirect to saleforce interface, login to your account and allow permission to Heroku app. Once everything is connected, you can now create new mapping. Goto Heroku Connect dashboard and click Create Mapping. Select the custom object you want to sync.

You will be taken to the mapping configuration. You can see 3 main parts in this page. First is the Salesforce ➡ Database, this will enable sync from salesforce to postgres, optional selection is the Steaming API, where it will update in almost realtime. Second is the Database ➡ Salesforce, this will enable the 2 way sync from postgres to salesforce. To properly enable this feature we need to set an upsert field, this will tell Heroku Connect to check for this key to determine either insert or update method is applied. The third is the Mapped Fields, and pretty straight forward, just select fields you want to map and Heroku Connect will automatically create a postgres table and corresponding fields selected. If everything is done, click save.

You will be taken to Heroku Connect dashboard. Wait for few moments and the mapping should sync. Click on the newly created mapping to check the status and to see the records. You can now create new records in salesforce and it should be automatically reflected to your postgres database.

Explorer view:

