Update the Application
server.js file in the root directory contains the server-side Node.js application. If you edit that file, you see the SQL statement used to update the database:
UPDATE salesforce.Contact SET Phone = $1, MobilePhone = $1 WHERE ...
Modify that line to also set the
... SET Phone = $1, HomePhone = $1, MobilePhone = $1 WHERE ...
Restart the Node.js app by first stopping the process (Ctrl-C) and then re-running the startup command:
DATABASE_URL=`heroku config:get DATABASE_URL` PGSSLMODE=require npm start
You can now test the change locally by using the app, changing a contact's phone number, and verifying in Salesforce that the three specified phone numbers were updated.
After you've verified the change locally, you can redeploy the changes. First stop the Node.js server process (Ctrl-C). Then commit the changes to the local git repository using the git command line:
git commit -am "also set the home phone"
Now push (upload) your git repository to Heroku:
git push heroku master
Heroku automatically rebuilds the application and deploys the new version.
This section exemplifies working with Heroku. The entire platform is designed for building, deploying, and scaling applications with ease. Simply pushing a new version of the source code is enough for Heroku to handle the rest.
To test the new version of your application, open your Heroku app by entering
http://APP_NAME.herokuapp.com in a browser window, and replacing
APP_Name with your app name. Fill in the form to change a contact's phone number using the following values:
- First Name: Tim
- Last Name: Barr
- Email: email@example.com
- Phone: (303) 555-1212
Click Update Phone Number.
This time, your app should also update the Home Phone as well as the Phone and Mobile fields. Verify this by hopping over to your Trailhead Playground and refreshing the page that displays the Tim Barr contact record.
Syncing could take a few minutes so before running the verification test below, check the record in Salesforce to confirm it has been updated.
Congratulations! You just synced up a Heroku Postgres database with Salesforce with just a few clicks. To learn more about Heroku, head over to the Heroku Dev Center.