Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Node.js Behavior in Heroku
      • Working with Node.js
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • AI Models
      • Inference Essentials
      • Inference API
      • Quick Start Guides
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Heroku Enterprise
  • Heroku Connect (Salesforce sync)
  • Heroku External Objects with Salesforce Connect

Heroku External Objects with Salesforce Connect

English — 日本語に切り替える

Last updated May 30, 2024

Table of Contents

  • Introduction
  • Setting up Heroku External Objects
  • Using Salesforce Connect
  • Resetting Your Credentials
  • References
  • Appendix: Importing Sample Data

Introduction

This guide shows how to use Heroku External Objects and Salesforce Connect to integrate data from a Heroku Postgres database into Salesforce. All of this is done by reference: the data remains in Heroku Postgres, but it can be read from and, in most cases, written to from within Salesforce.

Heroku External Objects works with Heroku Connect enterprise and shield plans. demo plans are unsupported.

Overview diagram

The PostgreSQL data that we are using is from a sample DVD rental database. See the Appendix section for instructions on how to import the data into a Heroku Postgres database.

Salesforce Connect is a separate product from Heroku Connect. If you don’t already have Salesforce Connect, contact Salesforce for licensing information.

Setting up Heroku External Objects

As a prerequisite, you must provision the Heroku Connect add-on. Using Heroku Connect to sync data with Salesforce is optional: if you’re only interested in Heroku External Objects, you can skip the step that asks you to authorize your connection with Salesforce.

You’ll see an External Objects tab on your Heroku Connect dashboard:

Heroku Connect dashboard with External Objects tab

If it’s your first time using Heroku External Objects, you’re prompted to create the OData service’s login credentials. After you’ve completed this step, you can view and manage the login credentials at any time from the dashboard. Heroku External Objects UI - 'Show credentials' button

Note the OData 4.0 service URL: Heroku External Objects UI - list of OData URLs

To complete the setup, you must choose the tables and/or views to expose. All schema within your Heroku Postgres database is available, including those schema not actively managed by Heroku Connect.

Unlike tables, views don’t currently support writes. Additionally, Connect requires that each view contain a uniquely valued column named ‘id’.

Heroku External Objects UI- table selection

Using Salesforce Connect

Now we can set up the OData service as an External Data Source in your Salesforce org. In the Salesforce setup menu, type “External” into the quick find box and choose “External Data Sources”. The interface for creating a new external data source looks like this:

Salesforce UI - New External Data Source

Be sure to select Writable External Objects if you’d like to use the read/write capabilities of OData 4.0.

Since we use a single password, choose “Named Principal” as the Identity Type and “Password Authentication” as the Authentication Protocol. Your username and password are available from the Heroku External Objects dashboard. If you reset your Heroku External Objects credentials, you must also update the username and password in your Salesforce setup.

After saving your External Data Source, click Validate and Sync to check the connection and synchronize its schema.

Salesforce UI - validate and sync external data source

Each table you select is an External Object. Initially their names have $ characters instead of periods, but you can edit the labels.

Salesforce UI - External Objects

We can call ours “External Customer”.

Salesforce UI - Edit label of external object

Like any other object, you can create custom object tabs and customize layouts for External Objects.

Salesforce UI - external object tab

We can also make SOQL queries against our external object, which has the API name public_customer__x.

SELECT Contact__c, first_name__c, last_name__c FROM public_customer__x

And since we enabled writes, any create/update/delete operations are written to the Heroku Postgres database.

Using External IDs to Relate External Objects

We can also use external IDs to associate records in Salesforce with their corresponding records in Postgres. Let’s create an external ID field on Salesforce contact objects, which links the records using the customer’s email address.

Create a new custom field on Contact and select String as the type. The value of the field is the customer’s email address, and it must be defined as a unique external ID:

Salesforce UI - new custom field

Now we can add an indirect lookup relationship on the external object:

Salesforce UI - indirect lookup relationship

On the next screens, relate it to the Contact object (Step 2) and choose the external ID field (Step 3).

In Step 4, be sure to specify email as the external column name.

Salesforce UI - new relationship, step 4: name of lookup field

We’re done – contacts in Salesforce with External Email Address fields are now related to their External Customer records. Clicking the email address link on this External Customer record takes us to Mary’s contact record in Salesforce.

Salesforce UI - external customer record

Mary’s contact record also has a related list that links back to the external object.

Salesforce UI - external customer relation on contact record

Resetting Your Credentials

When you reset your Heroku External Objects credentials, your old credentials are still available for 10 minutes so that you can update your integrations without incurring downtime.

To reset your Heroku External Objects credentials, do the following:

  1. Locate your connection in the Heroku Connect dashboard, and click the External Objects tab.

  2. Click “Reset credentials”.

  3. Click “Yes” when prompted to reset the credentials.

  4. Assuming that you have External Objects defined in Salesforce, edit your existing OData 4.0 External Data Source in Salesforce to use the new credentials.

References

  • Salesforce Connect documentation
  • OData 2.0 and 4.0 Adapter documentation
  • Salesforce Connect Trailhead module

Appendix: Importing Sample Data

Importing the data from the sample DVD rental database to Heroku Postgres requires you to:

  • Download and extract the sample database
  • Import the database to your local PostgresSQL server
  • Export the database to a dump file
  • Import the database dump to Heroku Postgres

It’s not possible to import the dvdrental.tar file directly to Heroku Postgres because it’s not in the format the Heroku Postgres requires.

Keep reading

  • Heroku Connect (Salesforce sync)

Feedback

Log in to submit feedback.

Writing Data to Salesforce with Heroku Connect Optimizing Heroku Connect Performance

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices