Last updated 20 October 2019
Table of Contents
Heroku Connect is an add-on that synchronizes data between your Salesforce organization and a Heroku Postgres database. Using Heroku Connect with Heroku Postgres, you can build applications that interact with your Salesforce data using your favorite tools, including all languages and frameworks supported by Heroku. If you are just getting started with Heroku Connect, see this step-by-step tutorial for deploying an application.
This is an overview article. The Heroku Connect Category contains more detailed information.
Provisioning the add-on
Heroku Connect can only be used with Salesforce editions that have API access. Some plan types, including trial versions, do not have API access by default and cannot be used with Heroku Connect.
To quickly create a new application, database and Heroku Connect instance use the Heroku button. To add Heroku Connect to an existing application you can either use the Heroku Dashboard or the Heroku CLI.
There are three plans for Heroku Connect:
demo: This is the default plan when provisioning the add-on and provides access to all features of Heroku Connect with the following limitations:
enterprise: This is the paid plan that you will use after purchasing Heroku Connect. If you have existing add-ons using the
demoplan, you can upgrade them by following the steps in the Upgrading the add-on plan section. Rows allocated to you under your contract are calculated according to the total rows synchronized across all mappings, regardless of how often they change.
enterprise plan was called
shield: This is the paid plan that you will use after purchasing Heroku Shield Connect. Heroku Shield Connect can only synchronize data with Heroku Postgres databases that have shield plans.
danketsu plans will appear with a ‘contract’ price in the add-ons list for your application in the Heroku dashboard. You should verify that the plan name is enterprise, shield, or danketsu if you wish to ensure that you are using a paid plan.
Please contact sales for more information on the Heroku Connect
You can use the
heroku addons command to see if your application already has Heroku Connect provisioned and the current plan:
$ heroku addons | grep herokuconnect herokuconnect (herokuconnect-gladly-8321) demo free
Create a new instance
Heroku Connect can be attached to your application using:
$ heroku addons:create herokuconnect Creating herokuconnect-gladly-8321... done, (free) Adding herokuconnect-gladly-8321 to sleepy-ocean-5276... done Use `heroku addons:open herokuconnect` to finish setup Use `heroku addons:docs herokuconnect` to view documentation.
When you provision the add-on a globally unique identifier will automatically be generated: in the above example the unique identifier is
herokuconnect-gladly-8321. You can specify your own unique identifier by passing the
--name flag to the
If you have purchased Heroku Connect you can specify the
enterprise plan when adding the add-on to your application using:
$ heroku addons:create herokuconnect:enterprise
Heroku Connect instances are located in the same region as the application that they are attached to.
When the Heroku Connect add-on has been attached to your application you can complete configuration by navigating to the add-on from the Heroku Dashboard or from the CLI:
$ heroku addons:open herokuconnect
In order to complete the configuration you will need a Postgres database attached to your application that Heroku Connect can use to store data for your mapped Salesforce objects.
Heroku Connect supports the following Heroku Postgres plan types: standard, premium and private. Heroku Connect can be used to sync data between a Salesforce org and a Heroku Postgres database inside or outside a Heroku Private Space.
It’s important to carefully consider the solution architecture of geographically distributed architectures as network latency can become a significant factor in service performance. The best practice is to co-locate Connect and Postgres in the same region, as geographically close to the Salesforce org as possible.
Although it is possible to use a hobby tier database with Heroku Connect it is strongly recommended that you use a standard tier Heroku Postgres database or premium tier Heroku Postgres database. Hobby tier databases have limited row and connection counts that can be consumed quickly if you configure multiple mappings in Heroku Connect.
To complete configuration of Heroku Connect click the
Setup Connection button in the dashboard.
- Choose a Heroku Postgres database that is attached to your application.
If you have multiple databases attached to your application you can choose the one you want Heroku Connect to use. The database specified by the
DATABASE_URL config var will be selected by default.
You can also choose the Postgres schema to be used for the tables created by Heroku Connect. The default is
salesforce however you can choose to put your tables in an existing schema, including
public, as long as no tables exist in the schema.
Next to set up the database.
- You then need to authenticate to your Salesforce organization: you can choose to authenticate to a production or sandbox organization or you can choose to use a custom login domain. Click the
Authorizebutton and you will be taken to Salesforce to enter your login credentials and authorize Heroku Connect to have access to your data.
You have the option to select the Salesforce API version you want Heroku Connect to use. Once selected, the API version cannot be changed. It is straightforward to create a second instance using a different API version with the same configuration should you wish to change API version at a later date.
It is recommended that you use a dedicated integration user for Heroku Connect with the necessary permissions to allow for successful synchronization (for example the most permissive option is to make the integration user a System Administrator).
To ensure optimal performance, Heroku Connect should have View All Data permission in Salesforce and it may also be necessary to grant Modify All Data permission when dealing with relationships between objects. Both the user and the Salesforce organization will also need to have API Enabled permission granted.
Without the View All Data permission, Salesforce has to check permissions for each row individually, which precludes use of indices and results in greatly reduced performance. For larger connections, lack of View All Data can also result in
OPERATION_TOO_LARGE errors that cause sync to fail altogether.
When authenticating to an organization it will not be possible to change the organization at a later date: see Salesforce organizations for more information.
Multiple instances of Heroku Connect
It is possible to add multiple Heroku Connect add-ons to a single application; for example, you may wish to synchronize data from multiple Salesforce organizations and one way to achieve this is to have multiple add-ons each authorized and configured to work with different organizations.
Using a different database schema name for each organization allows a single Heroku Postgres database to be used with multiple Heroku Connect add-ons.
It is also possible for multiple instances of Heroku Connect to be connected to the same Salesforce organization. This may be desirable to synchronize large numbers of Salesforce objects from a single organization.
When using multiple Heroku Connect add-ons, you must use a distinct integration user per add-on. Salesforce enforces a limit of ten concurrent queries per user. Additionally, each Heroku Connect add-on uses a different access token for Salesforce API calls, and Salesforce has a default limit of five tokens per integration user. If you use the same integration user for multiple add-ons and exceed the limit, your connections will require frequent re-authorization into Salesforce, which will repeatedly pause synchronization.
When multiple Heroku Connect add-ons exist it is necessary to use the globally unique identifier assigned to the add-on when running commands from the CLI. For example to open the Heroku Connect dashboard:
$ heroku addons:open herokuconnect-gladly-8321
Upgrading the add-on plan
If you are operating inside a Heroku team with a paid plan entitlement, you can upgrade by using the
Edit plan option in the Heroku Dashboard or using the CLI:
$ heroku addons:upgrade herokuconnect:enterprise WARNING: No add-on name specified (see `heroku help addons:upgrade`) Finding add-on from service herokuconnect on app sleepy-ocean-5276... done Found herokuconnect-gladly-8321 (herokuconnect:demo) on sleepy-ocean-5276. Changing herokuconnect-gladly-8321 plan to herokuconnect:enterprise... done, (contract) Plan change successful
If you have multiple Heroku Connect add-ons attached to your application you will also need to specify the globally unique identifier assigned to the add-on when running the upgrade command:
$ heroku addons:upgrade herokuconnect-gladly-8321 herokuconnect:enterprise Changing herokuconnect-gladly-8321 plan to herokuconnect:enterprise... done, (contract) Plan change successful
The Heroku Connect dashboard
The Heroku Connect dashboard allows you to configure, monitor and troubleshoot your connection.
The Heroku Connect dashboard is available to any member or collaborator on your application. See Collaborating with Other Developers on Your App for more information on how to manage the users who have access to your application.
Overview tab provides a summary of your mappings and key associated metrics. Depending upon your configuration, there will be either one or two histograms displaying data movement from Salesforce to Heroku Postgres, and optionally from Heroku Postgres to Salesforce.
When present, errors for reads and writes are displayed in orange. You can highlight a data point to see the specific number of rows and errors and change the time period shown using the drop-down list to the top-right of the chart.
Mappings tab lists each mapping in the connection along with a set of key data points: mapped fields, Salesforce rows, Postgres rows, pending writes, and errored writes. The action button to the right of each row can be used to launch mapping-specific actions such as edit, reload and abort. Lastly, the mapping name is a hyperlink to the mapping detail view where you can view mapping-specific data movement graphs and see details of each mapped field.
Logs tab allows you to view detailed information about the synchronization operations being performed by Heroku Connect as they happen. You can filter by mapped object, log type, and log level. To see and analyze historical logs, you need to configure a log drain.
Explorer tab provides access to Sync Explorer: a tool that allows you to get detailed information on the status of individual rows for each mapping.
You can filter by mapping and synchronization state (see Status information for details) and can search for text contained in the
Sync Explorer also allows you to view a side-by-side comparison of the data held in Salesforce and in the mapped database table.
Sync Explorer, used in conjunction with the Logs tab, is an invaluable tool to help you understand the operations being performed by Heroku Connect and enables you to diagnose and fix synchronization issues that can occur.
The most common synchronization error that occurs when reading is insufficient permissions to read the mapped object. The most common synchronization error that occurs when writing is insufficient write permissions for the target Salesforce org.
Settings tab contains a drop-down list where you can choose:
Manage Connection page lets you Pause or Resume the connection, view your plan type, view the list of users with access to the dashboard, check for orphaned mappings, download an audit trail and even delete the connection itself.
Manage Salesforce page shows your current connection details (Salesforce organization ID, authenticating user and environment). You can also re-authorize the user credentials used to access Salesforce and view your current Salesforce storage usage. Re-authorizing to a different user should not have any affect on the syncing of data, provided that the new user has permissions to the same objects that the previous user had.
Database page summarizes the Heroku Postgres database settings used by Heroku Connect, including the database and schema names, host and port, as well as providing useful command line examples showing how to connect to the database using PSQL.
It is possible to export your existing mapping configuration to or import a new configuration from a JSON file. This can be helpful when managing your Salesforce organizations.
Creating a mapping
To create a new mapping:
Create Mappingbutton on the Mappings tab of the Heroku Connect dashboard.
You will see a list of objects that can be mapped from your Salesforce organization. Use the search box to filter the list and then click on the object that you want to map.
Heroku Connect supports all standard and custom objects that can be retrieved via the SOAP and Bulk APIs except for those that require the use of object specific filter criteria or are not fully supported by the Bulk API. For example
KnowledgeArticleVersionand objects that end with
__kavrequire the use of additional query criteria (
PublishStatus=Online) and therefore cannot be mapped in Heroku Connect.
LeadHistorydoes not support Bulk Paging and the Base64 type of
Attachmentis unsupported by the Bulk API, and thus neither can be retrieved, once there are more than 20,000 changed records to sync. Other exceptions and warnings may apply.
The complete list of objects that Heroku Connect supports for your version of Salesforce is available from the Supported Salesforce Standard Objects page.
You will now be able to choose the synchronization options and the fields that you want to map. Some fields in the list are pre-selected and cannot be removed from the mapping (such as
SystemModstamp) as they are required for Heroku Connect to perform synchronization.
It is recommended that certain fields, such as
Name, are mapped to ensure you get the best experience from Heroku Connect. These fields will be pre-selected when creating a new mapping however unlike required fields they can be un-selected if you prefer not to include them.
To help optimize common queries Connect allows you to configure, one or more simple indexes for a Mapping. This can be done by checking the checkbox, in the
Indexedcolumn, for each field you wish to be indexed. Alternatively, if complex indexes are desired, these can be created via PostgreSQL manually. The advantage of creating simple indexes via Connect rather than manually, is they will be preserved when importing a Connect configuration into another Connection.
Saveand Heroku Connect will immediately create a table in your database corresponding to the Salesforce object, query for all records from Salesforce and insert them into the mapping table.
Editing a mapping
To edit an existing mapping:
- Click on the
Mappingstab of the Heroku Connect dashboard.
- On the mapping detail page, click the action item and select
Editfrom the menu.
- You will now be able to edit the synchronization options as well as adding and removing fields from the mapping.
Saveand Heroku Connect will update the mapped database table to add and remove columns and query Salesforce for data for any new fields to update existing records in the database.
Deleting a mapping
This is a destructive action that will cause you to lose data.
To delete an existing mapping:
- Click on the
Mappingstab of the Heroku Connect dashboard.
- On the mapping detail page, click the action item and select
Editfrom the menu.
- On the mapping editor page click the
When you delete a mapping from Connect the underlying data table in Postgres will also be removed. Furthermore, Connect will attempt to remove any pending writes corresponding to the mapping from your trigger log.
Write database updates
Mappings are read-only by default: Heroku Connect will poll your Salesforce organization for changes and synchronize them to your database. In read-only mode, changes made in your database will not be synchronized back to Salesforce.
To enable changes made in your database to synchronize back to your Salesforce organization, tick the
Write database updates box in the
Database > Salesforce section of the create/edit mapping page. See Writing to Salesforce for more details about how Connect writes to Salesforce.
Heroku Connect will poll your database for updates every two minutes. If updates are detected, Heroku Connect will begin to write changes back to Salesforce. Heroku Connect will not poll for additional database updates while the write operation to Salesforce is underway; write operations are executed in serial across all mappings in chronological order.
Once a given write operation is completed, the poll cycle begins again every two minutes. In addition to the two minute poll, your database will also attempt to detect new or updated records and notify Connect to initiate a poll using
pg_notify. This notification will happen at most every 10 seconds. These intervals are not configurable.
By default Heroku Connect will poll your Salesforce organization for changes every ten minutes. You can change the polling interval from as low as two minutes (ten minutes in the demo plan) to as high as sixty minutes in one minute increments. A shorter polling interval is suitable for mappings where data changes frequently and a longer polling interval is best for mappings that change less often as it reduces API usage and processing overheads.
The behavior of polling in Heroku Connect can be augmented by enabling accelerated polling, which makes use of Salesforce’s Streaming API to notify Heroku Connect when data changes in your mapped objects from Salesforce. Heroku Connect makes use of these notifications from Salesforce to trigger polling outside of the regularly scheduled polls. However, Connect does not rely on the notifications to determine what data has changed. You can think of the accelerated polling option as 'polling on demand’ whereas polling mode is 'polling at a fixed interval’. Accelerated polling is available for all custom objects and some standard objects. For those objects that do not support streaming, you will not be able to select this option when creating or editing a mapping.
If multiple notifications are received within a ten second period, Connect will only trigger a single poll to reduce Salesforce API utilization.
Streaming is not a reliable indicator of change, and operates on a best effort basis. To avoid interruptions to sync Connect will continue to automatically fallback to interval polling in accordance with the specified polling interval when streaming notifications are not received.
Accelerated polling only affects synchronizing data from Salesforce to Heroku, not synchronizing data from Heroku to Salesforce.
Heroku Connect read-write mappings work best when there is a shared notion of a uniqueness between Postgres and Salesforce. Records inserted in Postgres are unable to have a Salesforce generated ID until they get propagated via Heroku Connect. Because Heroku Connect uses separate threads for reading and writing, there exists a possibility that a reader may process a write operation from Salesforce to Postgres before a write process from Postgres to Salesforce has finished writing the newly generated Salesforce ID back to the inserted records.
Salesforce provides a mechanism to define a custom field to uniquely identify records coming from an external source (like Postgres/Heroku Connect) via the External ID and Unique attributes. Both attributes need to be enabled in order for a field to be chosen as the unique identifier. When this setting is configured, Heroku Connect matches records coming from Salesforce either by Salesforce ID (if available) or the specified unique identifier if a record matches the External ID and the Salesforce ID is NULL. This ensures that no matter which process attempts to write the record first, there are no integrity errors and the record is always matched (See Ensuring Uniqueness). You can also reference the newly inserted row from a foreign table by this external id (see: Simple Relationships Between Two Objects and Relationship External IDs).
Newly created custom fields may be hidden by default, even if the user is a System Administrator. After creating a custom field, we recommend you navigate to the custom field editor and click on
View Field Accessibility where you’ll be able to view and edit permissions as required.
The External ID values should not be changed as this could lead to a lack of parity in the data synced between your database and Salesforce.
There are several considerations to keep in mind while using unique external IDs with Heroku Connect. Unique external IDs should be treated as aliases for a Salesforce ID. Therefore, they should not change over time and you should choose a similarly unique mechanism for generating them. We recommend using random UUIDs, which can be generated using
gen_random_uuid(). Postgres integer sequences are not recommended as they are not guaranteed to be unique. Additionally, the ID field in the Heroku Connect database should not be used since these numbers can reset when importing your configuration into a new database or on reload a table.
As part of the provisioning process for Heroku Connect you will be required to authenticate to a Salesforce organization.
When you authenticate Heroku Connect to an organization then the mappings you create are specific to that organization: this includes both the structure of the underlying database tables and the data that is synchronized between Salesforce and the database. In order to reduce the potential for data conflict and corruption it is not possible to re-authenticate an existing Heroku Connect connection to a different Salesforce organization.
Sandbox organizations can be periodically refreshed: this involves creating a new snapshot of data from the production organization and, at the point of activation, will replace the current sandbox with a new organization.
If you want to synchronize data from a new production or a refreshed sandbox organization you will need to:
Export your current configuration to a JSON file.
Navigate to the
Import/Export Configuration, click the
Exportbutton and then on the confirmation page click
Exportto download the file. If connected to a sandbox that’s already been refreshed, the connection’s dashboard will be replaced by a link to these instructions and a button to export your configuration.
Import the JSON configuration file.
Navigate to the
Import/Export Configuration, click the
Importbutton and then click
Choose fileto locate the file to upload. Click the
Uploadbutton to begin the import.
On successful completion of the import Heroku Connect will begin syncing data from your new Salesforce organization into the database.
Login IP restrictions
If your Salesforce organization has org-wide or profile-based IP restrictions, you will need to extend your range of allowed IP addresses to include Heroku Connect. Connect runs inside a Private Space, so you can add these IPs to your allowed list depending on the cell your connection is in:
You can find your connection’s cell by going to the connection’s Manage Connection page and finding the Cell Label value.
You can verify that Heroku Connect is logging in successfully by viewing the Login History for your Salesforce organization. You should see entries where the Username matches the email address you have used to authenticate and the Application is either
Heroku Connect or
Heroku Connect EU depending on the region where your instance is located.
Salesforce has a session setting that allows you to lock sessions to the IP address from which they originated. Because Heroku Connect uses multiple IP addresses, you should avoid enabling this setting.
Heroku Connect observes Salesforce secure practices by storing an OAuth token which can be revoked at any time by the Salesforce admin. Heroku Connect uses secure SSL connections whenever data moves from Salesforce to the Heroku Postgres database, or from the Heroku Postgres database to Salesforce. Encrypted data may travel over the public internet while in flight and may be temporarily stored on an encrypted volume for up to 24 hours while being processed but otherwise is not stored outside of your Heroku Postgres database.
More information on Heroku security can be found here.
Using with Heroku Shield
For more detailed information on Heroku Connect usage and features, see the Heroku Connect category page.
Removing the add-on
You can remove the add-on using the Heroku dashboard or using the CLI.
Mapped tables will be dropped from your Postgres database when removing the add-on: you should ensure you have an up-to-date backup of your database before proceeding.
When you remove your add-on, we will try to
DROP SCHEMA for your connection schema. The schema will not be dropped if there are any remaining tables or functions associated with the schema.
$ heroku addons:destroy herokuconnect ! WARNING: Destructive Action ! This command will affect the app: sleepy-ocean-5276 ! To proceed, type "sleepy-ocean-5276" or re-run this command with --confirm sleepy-ocean-5276 > sleepy-ocean-5276 Destroying herokuconnect-gladly-8321 on sleepy-ocean-5276... done
If you have multiple Heroku Connect add-ons attached to your application you will also need to specify the globally unique identifier assigned to the add-on you wish to remove when using the CLI.
All Heroku Connect support and runtime issues should be submitted via one of the Heroku Support channels.