Heroku provides a cloud application platform to create, run, and work with your cloud based application. Thus, Heroku is termed as PaaS (Platform as a Service). Heroku supports several programming languages like JAVA, Node.js, Python, PHP, etc. The main reason for integrating Salesforce with Heroku is to provide a sophisticated custom user interface which we can develop using JAVA, Node.js, PHP, etc. It also supports replication of data from Salesforce using Heroku Postgres Database. There are many methods to integrate Heroku with Salesforce like Heroku Connect, Salesforce connect, Salesforce Rest API’s, Canvas Callouts, etc. In this article, we are going to see the integration part of the Heroku connect with Salesforce. Before diving into the integration part, let’s have an introduction of what Heroku Connect and Postgres is,
Heroku Connect – It is an Add-on available in Heroku which supports us to integrate Salesforce and Heroku.
Heroku Postgres Database – It is the SQL database service which runs by Heroku and this is also available as Add-on in Heroku.

Let’s start to integrate Salesforce with Heroku.
Prerequisites
- Salesforce Developer Account
- Heroku Account
- Install pgAdmin (Download[Symbol]pgadmin4-1.1-x86.exe) in your local system.
Creating an Heroku Application
- Log into to your Heroku Account and click “Create New App”.

Provide your App Name and select Runtime (Your App can run in your choice of a region) for your application. Then, click “Create App”.

Heroku Add-ons
2. Go to the menu at the top and click on “Resources”.

Under Add-ons, type “Heroku Connect” [Symbol] select the “Heroku Connect” Add-on [Symbol] Select the plan name as “Demo Edition – Free” and then click provision to add Heroku connect in your application. We can also have other add-ons available in Heroku and use them based on our needs.
Here, I used free edition for my application. Paid version is also available depending upon the user requirements.

Again Click on “Resources” [Symbol] Type “Heroku Postgres” in the Add-ons [Symbol] Select a plan name as “Hobby Dev – Free” and then click provision.
Now, you have added both Heroku Connect and Heroku Postgres database in your application.
Integrate Salesforce with Heroku
You have the required add-ons for the integration and now it’s time to get connect your Salesforce account with your heroku application.
3. From your Heroku application, select Resources [Symbol] Heroku Connect add-ons [Symbol] click Setup Connection. Enter Schema name and then click next.

Enter your Environment as production (Salesforce developer account is available under production option), and select your API Version and click Authorize.

It will redirect you to the Salesforce login page. Provide your Salesforce username and password and then click login. Now, your Salesforce account will get connected with Heroku.
Create Mapping
4. You can map the Salesforce object of your choice with Heroku.
From your Heroku app, select Resources [Symbol] Heroku Connect add-ons [Symbol] Create Mapping.
Select the object you want to map, and then select the fields to sync with your application.
The required fields are get selected by default. You are not allowed to unselect them.
For example, map your Account object from Salesforce to Heroku and check AccountId & AccountNumber fields to sync with your Heroku account.

Check “Listen for updates using streaming API” and check “write to salesforce any update to your database”. Select upsert field of your choice (when writing data to Salesforce, this field maps the external Id).

Data which are associated with the salesforce object will get synchronized with the Heroku application. It frequently polls and sync data from Salesforce. You can view the Salesforce data by clicking “Explorer” from the menu at the top. Extend the Salesforce record and click “Data” to view your salesforce record detail.

Extend a record and click “Data” to view the salesforce record.


Access Heroku Database using pgAdmin
5. You can access your Heroku database on the local system by using pgAdmin. Download and install pgadmin4-1.1-x86.exe from the following link.
https://www.postgresql.org/ftp/pgadmin3/pgadmin4/v1.1/windows/
Open pgAdmin on your system and right click on the server [Symbol] create [Symbol] server.

In general tab, enter Name, Server group, and check “connect now”.

In connection tab, Provide your Heroku database details. From your Heroku application, select Resources [Symbol] Heroku Postgres Add-ons [Symbol] click View credentials near database credentials.


Copy & paste all the required database details from Heroku to pgAdmin Server connection, and click save.

You can find your database by clicking “Server”. It shows the entire database from Heroku and there you can find your database for which you have provided access.


Extend your database by clicking on the plus symbol at the right, extend schemas, extend salesforce[Symbol]extend Tables [Symbol] select your object. Right click on the object; select View Data[Symbol] View All Rows. You can see all your Salesforce data rows in pgAdmin.

You can also insert, update and delete record into your Heroku database using pgAdmin. These changes will automatically get sync with your Salesforce org.
Extend your database by clicking on the plus symbol at the right, extend schemas, extend salesforce[Symbol]extend Tables [Symbol] select your object [Symbol]Right click on the object [Symbol] select Query Tool. Write the database command as you need and execute it. It will sync with your Salesforce data. For example, if I need to insert account into Heroku database using command “Insert into Salesforce.account (name) values (“Heroku Connect Account”)”

You can view the number of records sent from Heroku to Salesforce in Heroku connect.

Limitations of Heroku Free Account:
Heroku provides both paid and unpaid version for the user, and it depends on how you need Heroku application. Heroku free account allows you to create a maximum of 5 application. Heroku Postgres “Hobby Dev – Free” provide 20 connection, 10,000 rows and 7.5 MB of data size at free of cost. If you want more features, pay and use the Heroku application and Add-ons as well.
Conclusion
Thus, the Heroku Connect with its easy configurations and easy access of add-ons provision with the click of a button make data sync between a Salesforce object and Heroku Postgres table much easier.