Salesforce

This IntegrationIntegration - An integration is the place the you write your code to get things done! Written in NodeJS, an integration runs in Fusebit's secure and scalable environment to translate between the needs of your backend application and the remote service or services you're connecting to. allows full access to the Salesforce API for cloud-hosted instances from your application. Fusebit's multi-tenant approach makes it easy for you to manage multiple Salesforce connections on behalf of your app's users. Our Node.js-based programming model and lightweight deployment story make it easy to customize the Integration with any necessary business logic.

Getting Started

  1. Use the Fusebit Management PortalFusebit Management Portal - The Fusebit Management Portal enables you to easily setup and manage all your integrations in one place. Link: https://manage.fusebit.io to create an account and log in.
  2. Create a new Integration using one of our Salesforce templates
  1. You will then be able to run the Integration, download it's code, modify it, and deploy your changes. Detailed instructions on how to get started with an Integration are available here.

Invoking the Salesforce API

The Integration template comes pre-configured with some example calls that invoke Salesforce's API, for example:

// For the Salesforce SDK documentation, see https://jsforce.github.io/.
  const contacts = await salesforceClient.query('SELECT count() FROM Contact');
  ctx.body = {
    message: `Successfully loaded ${contacts.totalSize} contacts from SFDC`,
  };

The salesforceClient object provided by Fusebit is an instance of the jsforce npm package. The full reference documentation for the package is available here.

Fusebit ensures the above SDK object is already bootstrapped with the Salesforce credentials of the user invoking the integration. You do not need to worry about obtaining an access token or refresh token -- Fusebit does that for you automatically.

Creating your own Salesforce App

Out of the box, Fusebit's Salesforce Integration uses our own demonstration application. This is to make it easier to get started, however you will likely need to register your own Salesforce App for use in production.

To create your own Salesforce App:

  1. From your Salesforce homepage, click on the Settings icon in the top right, and select 'Setup'
  1. In the sidebar, navigate to Apps > App Manager
  1. Click on 'New Connected App'
Salesforce has two types of apps you can create, [Connected Apps and Lightning Apps](https://www.forcetalks.com/salesforce-topic/what-is-difference-between-lightning-app-and-connected-app-in-salesforce/). If your app sits outside of Salesforce UI and is consuming the API only, then you will want to create a 'Connected App'.Salesforce has two types of apps you can create, [Connected Apps and Lightning Apps](https://www.forcetalks.com/salesforce-topic/what-is-difference-between-lightning-app-and-connected-app-in-salesforce/). If your app sits outside of Salesforce UI and is consuming the API only, then you will want to create a 'Connected App'.

Salesforce has two types of apps you can create, Connected Apps and Lightning Apps. If your app sits outside of Salesforce UI and is consuming the API only, then you will want to create a 'Connected App'.

  1. After filling out the Basic Information, you must click on 'Enable OAuth Settings' and also make sure the following items are selected:
  • Use digital signatures
  • Requires Secret for Web Flow
  • Require Secret for Refresh Token Flow

Additionally, you will want to define the App Scopes that you want to enable. You will need to configure these in the connector in the Fusebit Management Portal.

NOTE: If you select full access, it doesn’t return a refresh token. You must explicitly request the refresh_token scope to get a refresh token.NOTE: If you select full access, it doesn’t return a refresh token. You must explicitly request the refresh_token scope to get a refresh token.

NOTE: If you select full access, it doesn’t return a refresh token. You must explicitly request the refresh_token scope to get a refresh token.

  1. Back in the portal, find the Integration you would like to connect to the new Salesforce App you just created. Select the ConnectorConnector - A connector is the package from Fusebit that manages the relationship between one or more integrations and a specific service. One of the most common types of connector is an OAuth connector, which takes care of the OAuth negotiation between your customers and the service you're integrating, so that you don't have to! tied to that integration.
  1. Select Enable Production Credentials in the Connector Configuration and list the OAuth Scopes you specified in the Space separated scopes to request from the OAuth server field. To use the example provided later in this guide, specify the following scopes: api refresh_token offline_access.

Additionally, while you're here copy the 'OAuth2 Redirect URL'. You will need to paste this into the Salesforce App.

🚧

When switching a Connector to a different Salesforce App, all IdentityIdentity - An identity is a unique relationship one of your customers has with a service. An identity can be used by multiple integrations to act on that service on behalf of your customer. objects associated with that Connector will be deleted. Your users will need to re-authenticate against Salesforce after you make the change.

  1. Back in your Salesforce App and paste the 'OAuth2 Redirect URL' into the 'Callback URL' box and hit save.
  1. After you hit save, you will be taken to the Manage App screen for the app you just created. Copy the 'Consumer Key' and 'Consumer Secret', you will need to configure these in the connector in the Fusebit Management Portal.
  1. Back in the portal, paste the 'Consumer Key' in the 'Client ID' field, and the 'Consumer Secret' field in the 'Client Secret' field.

👍

Good Job!

Now, any time a new user installs your Integration, you should now see your Salesforce App information displayed during the authorization step.

Receiving events from Salesforce

Receiving events from Salesforce when an Opportunity or another object changes can be helpful when timeliness matters to your application. Check out Salesforce Apex Trigger Support for a walkthrough on how to set this up.

Helpful References

Want to learn more about building Connected Apps to integrate with Salesforce? Here are some helpful references:

Links:


Did this page help you?