Record Viewer - UI API + Node.js Sample App
Перейти к файлу
Jody Bleyle 048716e012 42.0 -> 43.0 2018-05-22 14:50:05 -07:00
app depGraphEditor, ObjectInfoDirectory, v42, jadeToPug 2018-03-14 16:56:09 -07:00
client-src 42.0 -> 43.0 2018-05-22 14:50:05 -07:00
lib depGraphEditor, ObjectInfoDirectory, v42, jadeToPug 2018-03-14 16:56:09 -07:00
nginx Automate self-signed SSL creation within the NGINX Dockerfile 2018-03-06 17:20:17 -08:00
views reference npm jquery instead of https://code.jquery.com (#47) 2018-05-07 15:13:35 -07:00
.gitignore git ignore update 2018-03-14 16:53:01 -07:00
Dockerfile depGraphEditor, ObjectInfoDirectory, v42, jadeToPug 2018-03-14 16:56:09 -07:00
LICENSE initial commit 2017-09-28 10:37:45 -07:00
Procfile initial commit 2017-09-28 10:37:45 -07:00
README.md Move "Use" topic up. 2018-04-24 10:59:52 -04:00
app.js reference npm jquery instead of https://code.jquery.com (#47) 2018-05-07 15:13:35 -07:00
app.json initial commit 2017-09-28 10:37:45 -07:00
docker-compose.yml depGraphEditor, ObjectInfoDirectory, v42, jadeToPug 2018-03-14 16:56:09 -07:00
package-lock.json fixing transitive dependency warnings 2018-04-24 23:55:13 -07:00
package.json reference npm jquery instead of https://code.jquery.com (#47) 2018-05-07 15:13:35 -07:00

README.md

RecordViewer—Node.js

This Node.js app shows you how easy it is to use the Salesforce User Interface API to create, read, update, and delete Salesforce records.

Salesforce uses User Interface API to build the Salesforce1 and Lightning Experience apps. Not only do you get data and metadata in a single response, but the response matches metadata changes made to the org by Salesforce admins. You dont have to worry about layouts, picklists, field-level security, or sharing—all you have to do is build an app that users love.

Set Up the App

  1. To authenticate Record Viewer with a Salesforce org, in the org, configure a connected app.
    • For the Callback URL, enter https://localhost:8443/oauth-redirect. If you deploy the app to Heroku, Heroku will provide a different callback URL. Create a new Connected App using the Heroku callback URL.
    • Make a note of the OAuth consumer key to enter on the home page of the Record Viewer app.
  2. To allow the app to make cross-domain requests to Salesforce, in the org, choose Setup > CORS.
    1. Click New.
    2. For Origin URL Pattern, enter https://localhost:8443. If you're deploying to heroku, enter https://*.herokuapp.com or https://some-domain.herokuapp.com.
  3. Clone the RecordViewer repository.
  4. Set up Docker.
  5. To build and start the servers, run this Docker Compose command.
    docker-compose build && docker-compose up -d
    
  6. After Docker finishes building and starts the containers, the web application is available at https://localhost:8443/.

Forward Ports

If you're running docker in a VM, be sure to forward the ports exposed in your containers. This script forwards open ports in the boot2docker-VM.

for i in {49000..49900}; do
    VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
    VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
done

Use the Record Viewer App

To view a record, click a record in the Recent Items list. This list contains recently used items. If you don't see any records, go to your Salesforce org and select a record or two, then return to the Record Viewer app.

When viewing a record, you can click to Edit, Delete, or Clone the record.

To create a record, navigate to the app's home page and select an object from the dropdown. User Interface API supports all custom objects and some standard objects. If you select an unsupported object, the app will let you know.

To see the response from User Interface API that the app uses to build the page, click Show JSON.

(Optional) Deploy to Heroku

Deploy

Deploy to Heroku Using Docker

All of the instructions below assume that you are within the root of the project directory.

  1. Install the Heroku CLI

  2. Log into Heroku through the command line

    heroku login
    
  3. Log into the Heroku Container Registry

    heroku container:login
    
  4. The Heroku application must be created

    heroku create
    
  5. Deploy the application

    heroku container:push web
    

(Optional) Set the Default Login URL and Consumer Key

After creating the Connected App in Salesforce, follow these steps to set the default Login URL and Consumer Key on the default page.

  1. To set the Login URL, run this command.

    heroku config:set LOGIN_URL={url}
    

    Substitute {url} with the URL of the server that the org is on.

  2. To set the Consumer Key, run this command.

    heroku config:set CONSUMER_KEY={key}
    

    Substitute {key} with the value from the Consumer Key field in the Connected App details.