Skip to content

Commit 2d8ab5c

Browse files
authored
Merge pull request #4 from heroku-examples/ga-updates
Initial GA updates
2 parents 7636e68 + 61a2db1 commit 2d8ab5c

File tree

4 files changed

+2024
-4909
lines changed

4 files changed

+2024
-4909
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Heroku Integration - Salesforce API Access (Node.js)
22

3-
> **Important**: For use with the Heroku Integration and Heroku Eventing pilots only
4-
53
## Architecture Overview
64

75
This sample application showcases how to extend a Heroku web application by integrating it with Salesforce APIs, enabling seamless data exchange and automation across multiple connected Salesforce orgs. It also includes a demonstration of the Salesforce Bulk API, which is optimized for handling large data volumes efficiently.
@@ -13,20 +11,20 @@ This sample application showcases how to extend a Heroku web application by inte
1311
* Heroku login
1412
* Heroku AppLink Pilot enabled
1513
* Heroku CLI installed
16-
* Heroku AppLink Pilot CLI plugin is installed
14+
* Heroku AppLink CLI plugin is installed
1715
* Salesforce CLI installed
1816
* Login information for one or more Scratch, Development or Sandbox orgs
19-
- Watch the [Introduction to the Heroku AppLink Pilot for Developers](https://www.youtube.com/watch?v=T5kOGNuTCLE) video
2017

2118
## Local Development and Testing
2219

2320
You do not need to deploy your application but you do need to configure it with Heroku.
2421

2522
```bash
2623
heroku create
27-
heroku addons:create heroku-integration
28-
heroku salesforce:connect my-org --store-as-run-as-user
24+
heroku addons:create heroku-applink
25+
heroku salesforce:authorizations:add my-org
2926
heroku config:set CONNECTION_NAMES=my-org
27+
heroku config:set HEROKU_APP_ID="$(heroku apps:info --json | jq -r '.app.id')"
3028
heroku config --shell > .env
3129
npm install
3230
npm start
@@ -36,15 +34,15 @@ Navigate to `http://localhost:5006` to observe a list of accounts from the conne
3634

3735
### Multiple Org Connections
3836

39-
To access multiple Salesforce orgs, repeat the `salesforce:connect` command above with different org logins and connection names, then update the `CONNECTION_NAMES` environment variable within the `.env` file with a comma delimiated list of connection names (example shown below). The sample code will automatically query for `Account` in each org and display the results.
37+
To access multiple Salesforce orgs, repeat the `salesforce:authorizations` command above with different org logins and connection names, then update the `CONNECTION_NAMES` environment variable within the `.env` file with a comma delimiated list of connection names (example shown below). The sample code will automatically query for `Account` in each org and display the results.
4038

4139
```
4240
CONNECTION_NAMES=my-org,my-org-sales-a
4341
```
4442

4543
### Bulk API Demo
4644

47-
This sample includes a demonstration of using the Salesforce Bulk API using connections formed with the Heroku Integration add-on. To see this in action obtain an org that is empty or that you are using for testing purposes only. Repeat the `salesforce:connect` command above using the connection name `empty-org` and then update the `CONNECTION_NAMES` environment variable within `.env` with a comma delimiated list of connection names (example shown above).
45+
This sample includes a demonstration of using the Salesforce Bulk API using connections formed with the Heroku Integration add-on. To see this in action obtain an org that is empty or that you are using for testing purposes only. Repeat the `salesforce:authorizations` command above using the connection name `empty-org` and then update the `CONNECTION_NAMES` environment variable within `.env` with a comma delimiated list of connection names (example shown above).
4846

4947
When you visit the `/bulk-demo` endpoint, the application will check for existing bulk-loaded records. If none are found, it will start an asynchronous bulk load process. You will see output in the console similar to this:
5048

@@ -83,20 +81,21 @@ echo "delete [SELECT Id FROM Account WHERE Name LIKE 'Bulk Account%'];" | sf ape
8381

8482
```bash
8583
heroku create
86-
heroku addons:create heroku-integration
87-
heroku salesforce:connect my-org --store-as-run-as-user
84+
heroku addons:create heroku-applink --wait
85+
heroku salesforce:authorizations:add my-org
8886
heroku config:set CONNECTION_NAMES=my-org
87+
heroku config:set HEROKU_APP_ID="$(heroku apps:info --json | jq -r '.app.id')"
8988
git push heroku main
9089
heroku open
9190
```
9291

93-
To access multiple Salesforce orgs, repeat the `salesforce:connect` command above with different org logins and connection names, then update the `CONNECTION_NAMES` with a comma delimiated list of connection names. The sample code will automatically query for `Account` in each org and display the results.
92+
To access multiple Salesforce orgs, repeat the `salesforce:authorizations` command above with different org logins and connection names, then update the `CONNECTION_NAMES` with a comma delimiated list of connection names. The sample code will automatically query for `Account` in each org and display the results.
9493

9594
## Technical Information
9695

97-
* Salesforce APIs are always accessed in the context of the authenticated user defined at the time of connection through the `--store-as-run-as-user` CLI parameter. This means that only the objects and fields the user has access to can be accessed by the code.
96+
* Salesforce APIs are always accessed in the context of the authenticated user. This means that only the objects and fields the user has access to can be accessed by the code.
9897
* This is a Node.js Express application, using EJS to render browser content. Other client libraries and frameworks can be used of course.
99-
* The application uses the `@heroku/salesforce-sdk-nodejs` package to handle Salesforce connections, authentication, and API interactions including SOQL queries and Bulk API operations.
98+
* The application uses the `@heroku/applink` package to handle Salesforce connections, authentication, and API interactions including SOQL queries and Bulk API operations.
10099
* The sample uses a custom environment variable `CONNECTION_NAMES` to enumerate the org connections to be used by the application. However this could easily be hardcoded in your own library code, or obtained from a configuration service or other preferred means of your choice.
101100
* The Bulk API demo intentionally showcases real-world duplicate handling scenarios. Some records may fail to insert due to Salesforce duplicate detection rules, which demonstrates proper error handling in bulk operations. Users can either accept this as a learning opportunity about integration resilience or temporarily disable duplicate rules in their Salesforce org for testing purposes. Successfully inserted records will still be visible on the main page, regardless of any duplicate-related failures.
102101

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require('dotenv').config();
22
const express = require('express')
33
const path = require('path')
4-
const { init } = require('@heroku/salesforce-sdk-nodejs')
4+
const { init } = require('@heroku/applink')
55

66
const port = process.env.PORT || 5006
77
const app = express()
@@ -23,7 +23,7 @@ app.get('/', async (req, res) => {
2323
connectionNames.map(async (connectionName) => {
2424
try {
2525
// Initialize connection for this org
26-
const org = await sdk.addons.herokuIntegration.getConnection(connectionName.trim())
26+
const org = await sdk.addons.applink.getAuthorization(connectionName.trim())
2727
console.log('Connected to Salesforce org:', {
2828
orgId: org.id,
2929
username: org.user.username
@@ -101,7 +101,7 @@ app.get('/bulk-demo', async (req, res) => {
101101
}
102102

103103
// Initialize connection for empty-org
104-
const org = await sdk.addons.herokuIntegration.getConnection(emptyOrgName)
104+
const org = await sdk.addons.applink.getAuthorization(emptyOrgName)
105105
console.log('Connected to empty-org:', {
106106
orgId: org.id,
107107
username: org.user.username

0 commit comments

Comments
 (0)