Heroku - 17 Heroku Connect
This lesson is the hands-on part of Heroku Connect. We will first create a Salesforce account so we have a valid Salesforce org to connect to. Second, we will configure Heroku Connect so that it is linked with the Heroku app and Postgres database we are about to create. Third, we will synchronize our first table between Heroku Postgres and Salesforce: in this example we use the standard Account object. Fourth, we will create a new Account row in Salesforce and verify it lands in Heroku Postgres. Finally we will change a value on the Heroku side and check that Salesforce receives the update.
Step 1 — Sign up for a Salesforce Developer Sandbox
Go to developer.salesforce.com, click Sign up, fill the form. Salesforce sends a confirmation email; once activated you get a free Developer Sandbox. In the org we open the Accounts tab, click New, fill the name and a billing street (in the demo: 123 Victor Hugo), save. The account is created — for now it is mostly empty, but it is enough to test the sync once Heroku Connect is configured.
Step 2 — Install Heroku Postgres and Heroku Connect
From a new (or existing) Heroku app, open the Resources tab and add the two add-ons we need:
- Heroku Postgres — the database that will receive the synced Salesforce data.
- Heroku Connect — the add-on that performs the actual sync.
Open Heroku Connect, click Setup Connection, leave the database choice as is (only one Postgres is attached), click Next, and authorize against your Salesforce Developer Sandbox. The "OK" badge confirms the connection is healthy.
Step 3 — Create a mapping for the Account object
Click Create Mapping and pick the Account object. You land on the mapping screen. Important options:
- Sync frequency — set to every 10 minutes by default. Accelerated sync is reserved for paid plans, so it does not concern us on the free plan.
- Write to Salesforce from Heroku Postgres — if you do not tick this checkbox, Heroku Connect will not push Postgres changes back to Salesforce, and any direct modification on the Heroku side will be lost at the next sync. Tick it to get a true two-way sync.
- External ID — a warning appears because Postgres has no native way to assign a Salesforce ID when a row is inserted on the Heroku side. To fix this, you need a field on the Account object that is marked unique, which then becomes selectable here. For the demo we add
billing_streetto the synced fields (it is the field we filled in earlier) and leave the rest as is, ignoring the External ID warning for simplicity.
Save the mapping. The dashboard now shows the number of mapped fields, the number of records in Salesforce and the number of rows in Postgres.
Step 4 — Verify in pgAdmin and test the two-way sync
Open pgAdmin and add the Heroku Postgres database as a new server (the credentials come from the Settings → View Credentials page on Heroku Postgres: host, database, user, password, port). Connect, browse the salesforce schema, open the account table: every Account that was synced appears there. In the demo, 14 records are visible — including the one we created earlier, with the billing street we entered.
To validate the reverse direction, we edit the billing_street field directly in pgAdmin (for example to 456 Victor Hugo) and save. The sync icon briefly switches to "syncing", which means the row has been picked up. Back in Salesforce, the Account's Billing Address is now 456 Victor Hugo: the change has flowed from Heroku Postgres to Salesforce. In normal operation you would wait up to 10 minutes for the next automatic sync, but the result confirms that data is transferred in both directions. See you in the next lesson.