Chapter 3. Implementing the Salesforce to database sample integration
This sample integration captures updates in Salesforce and then calls a database stored procedure, which synchronizes that database with the Salesforce updates.
You need an account in a Salesforce installation that is used for development. This account must have Salesforce API access, which is available in a Salesforce Enterprise account or a Salesforce Developer account. To obtain a free developer account, visit https://developer.salesforce.com/signup. It takes less than two minutes to obtain a Salesforce account.
If you already created the Twitter to Salesforce sample integration:
- Fuse Online is already registered as a Salesforce client. You do not need to do this again.
- You already have a Salesforce connection, which you can reuse in this sample integration.
If you did not already create the Twitter to Salesforce sample integration, then you must register Fuse Online as a Salesforce client and create a Salesforce connection in order to complete the Salesforce to database sample integration.
- You must be logged in to your Fuse Online environment.
- You are working in a Fuse Online environment that is running in an OpenShift Container Platform project in which an administrator added the Fuse Online sample data, which provides the PostgresDB connection and the To Do app for confirming that the integration works as expected.
To implement, deploy, and test this sample integration, the main steps are:
- Section 3.1, “Registering Fuse Online as a Salesforce client application”
- Section 3.2, “Creating a Salesforce connection”
- Section 3.3, “Creating and deploying the Salesforce to database sample integration”
- Section 3.4, “Confirming that the Salesforce to database integration works”
- Section 3.5, “Cleaning up your integration”
3.1. Registering Fuse Online as a Salesforce client application
In an integration, to connect to Salesforce, the first thing you must do is register your Fuse Online environment as a client application that can access Salesforce. This lets you create any number of integrations that connect to Salesforce. In other words, you need to register a particular Fuse Online environment with Salesforce only once.
In each Fuse Online environment, there can be only one registration of Fuse Online as a Salesforce client application. However, while each Salesforce connection uses the same registration, it can use different user credentials.
If you already registered Fuse Online as a Salesforce client and created a Salesforce connection, skip to Creating and deploying the Salesforce to database integration.
You are logged in to Fuse Online.
In Fuse Online:
- In the left panel, click Settings.
- On the Settings page, near the top, to the right of the callback URL, click to copy the callback URL for your Fuse Online environment to the clipboard. You will need this URL toward the end of this procedure.
- Click the Salesforce entry to display the Client ID and Client Secret fields.
In another browser tab, log in to your Salesforce account and follow the steps below to create a connected app. These instructions assume that you are using the Salesforce Classic user interface. To switch from the Salesforce Lightning Experience interface, click your profile icon and select Switch to Salesforce Classic. For additional information, see the Salesforce documentation for Create a Connected App.
- In Salesforce, in the upper right, click Setup.
- In the left panel, select Build > Create > Apps.
- Scroll down to Connected Apps and click New.
- Enter the required information and then select Enable OAuth Settings.
In the Callback URL field, paste your Fuse Online URL, which you copied at the beginning of this procedure. For example:
For OAuth Scopes, add:
- Manage user data via APIs (api)
- Access unique user identifiers (openid)
- Perform requests at any time (refresh_token, offline_accesss)
- Select Configure ID token and then Include Standard Claims.
- Scroll down and click Save.
- Scroll up to see that Salesforce indicates a short wait:
- Click Continue.
- Copy the consumer key that Salesforce provides.
- Return to your Fuse Online Settings page and paste the Salesforce-provided consumer key into the Fuse Online Salesforce Client ID field.
- Return to Salesforce and copy the consumer secret that Salesforce provides.
- Return to your Fuse Online Settings page and paste the Salesforce-provided consumer secret into the Fuse Online Salesforce Client Secret field.
- Click Save.
- Click the Salesforce entry to collapse it.
3.2. Creating a Salesforce connection
To create an integration that accesses data in Salesforce, you must first create a Salesforce connection. After you create a Salesforce connection, you can use it in multiple integrations.
- You are logged in to Fuse Online.
- Fuse Online is open in a web browser.
- You must have already registered your Fuse Online environment as an application that can access Salesforce.
You added the Salesforce client ID and client secret that you received after registration to the Fuse Online Settings page.
If you did not already register Fuse Online, see Registering Fuse Online as a Salesforce client application.
Be sure to wait 2 - 10 minutes after registering your Fuse Online installation as a Salesforce client before you try to create a Salesforce connection.
- In Fuse Online, in the left panel, click Connections to display available connections.
- Click Create Connection to display the available connectors. A connector is a template for creating one or more connections.
- Click the Salesforce connector.
Click Connect Salesforce to display a Salesforce authorization page. You might need to log in to Salesforce before you see the authorization page.
If Connect Salesforce does not appear, then your Fuse Online environment is not registered as a Salesforce client application. See Registering Fuse Online as a Salesforce client application. When you try to create a Salesforce connection and your Fuse Online environment is not registered as a Salesforce client application, then Fuse Online displays multiple fields that prompt for authorization information. While you can create a Salesforce connection by entering values in these fields, it is not recommended.Note
The following error indicates that Salesforce does not have the correct Fuse Online callback URL:
If you get this error message, then in Salesforce, ensure that the Fuse Online callback URL is specified according to the instructions in Registering Fuse Online as a Salesforce client application.
- Click Allow to return to Fuse Online.
In the Name field, enter your choice of a name that helps you distinguish this connection from any other connections. For example, enter
SF Connect 1.
In the Description field, optionally enter any information that is helpful to know about this connection. For example, enter
Sample Salesforce connection that uses my Salesforce login credentials.
- Click Save to see that the connection you created is now available. If you entered the example name, you would see that SF Connect 1 appears as a connection that you can choose to add to an integration.
3.3. Creating and deploying the Salesforce to database sample integration
To create and deploy an integration that uses the Salesforce connection that you created and the database connection that is provided with Fuse Online, the main steps are:
- You registered your Fuse Online environment as a Salesforce client.
- You created a Fuse Online Salesforce connection.
- Fuse Online is open and you are logged in.
3.3.1. Choosing the start connection
In Fuse Online, to create the sample Salesforce to database integration, the first task is to choose the start connection.
- You created a Salesforce connection.
- In Fuse Online, on the left, click Integrations.
- Click Create Integration.
- On the Choose a connection page, click your Salesforce connection. If you specified the example name, you would click SF Connect 1.
- On the Choose an action page, to the right of On create, click Select.
- In the Object name field, select Lead.
- Click Next to add the start connection to the integration.
When the integration is running, after connecting to Salesforce, the integration watches for notifications that a Salesforce Lead record was created. When the integration finds such a notification, it passes the new lead’s data to the next step in the integration. However, before you can add the next step, you must choose the integration’s finish connection.
3.3.2. Choosing the finish connection
In Fuse Online, to continue creating the Salesforce to database sample integration, after you add the start connection, you add the finish connection to the integration.
- You added the Salesforce connection to the integration as the start connection.
- Fuse Online is prompting you to add the finish connection.
- In Fuse Online, on the Choose a connection page, click the PostgresDB connection. This integration finishes by using the credentials defined in this database connection to connect to the provided sample database.
- On the Choose an action page, select Invoke stored procedure, which passes data to a stored procedure.
- In the Procedure name field, accept add_lead, which is the provided stored procedure to run in the sample database. The selected procedure determines the requirements for additional steps in the integration, for example, which Salesforce data fields need to be mapped to which database fields.
- Click Next to add the finish connection to the integration.
3.3.3. Adding a data mapping step
To continue creating the Salesforce to database sample integration, add a data mapping step that correlates Salesforce lead fields to fields in the sample database.
- The integration’s start connection is to Salesforce.
- The integration’s finish connection is to the PostgresDB sample database.
- In Fuse Online, in the integration visualization, click the plus sign.
- Click Data Mapper and wait a few moments. When the data fields appear, the Sources panel on the left displays the Salesforce fields and the Target panel on the right displays the database fields.
Map the Salesforce
Companyfield to the database
companyfield. On the left, in the Sources panel, click Company and drag it to the Target panel onto company.
The data mapper displays a line from the source field to the target field.
Map the Sources (Salesforce)
Map two Salesforce fields (
LastName) to the database
- In the Target panel, click first_and_last_name and then click the Create New Mapping icon.
In the Mapping Details panel, in the Sources field, select /FirstName and then select /LastName.
When you are done you should see a line from each of the source fields to the target field.
Add the following mappings:
Map This Salesforce Field To This Database Field
- In the upper right, click Done.
3.3.4. Giving the integration a name and deploying it
When the Salesforce to database sample integration is complete then you can deploy it and see how it works.
- The integration’s start connection is Salesforce.
- The integration’s finish connection is to the sample database that is provided with Fuse Online.
- You just added a data mapping step to the integration.
- In Fuse Online, in the upper right, click Publish to give it a name.
In the Name field, enter a name for the integration. For example,
Salesforce to Database Sample Integration.
- Optionally, in the Description field, enter information that might be helpful to know about this integration.
- Optionally, in the Labels field, add one or more labels. A label is a key-value pair tag that you can apply to an integration for later filtering and selecting in OpenShift. For example, an OpenShift admin user can filter the list of running pods or deployments by label.
Click Save and publish.
Fuse Online starts to deploy the integration and then displays the list of integrations in this environment. The entry for your Salesforce to database integration displays a progress indicator that shows the publishing stages. Fuse Online is generating the runtime for the integration and will start it when the runtime is ready. This takes a few minutes.
A Fuse Online account is limited to a specific number of integrations that can be running at one time. For details, see the pricing plan. If you are already running the maximum number of integrations, then you must stop an integration before you can start running another one.
If you are already running the maximum number of integrations, follow these steps to stop an integration:
- In the left panel, click Integrations.
- In the entry for the integration that you want to stop, click on the far right.
- In the popup, click Stop.
After stopping an integration, start another integration as follows:
- In the left panel, click Integrations.
- In the entry for the integration that you want to start, click on the far right.
- In the popup, click Publish.
3.4. Confirming that the Salesforce to database integration works
To confirm that the Salesforce to database integration is working, create a new lead in Salesforce and then open the web app that Fuse Online provides for viewing updates to the sample database.
- In Fuse Online, Running appears next to the name that you specified for the Salesforce to database sample integration when you published it.
- You can access your Salesforce account.
- In the left panel, click Integrations.
- If necessary, wait until your sample integration is a Running integration. If you used the example name, you would see that Salesforce to Database Sample Integration is Running.
- In your Salesforce installation, create a new lead. Be sure to enter data in the fields that you mapped: Company, Email, FirstName, LastName, LeadSource, Status, Phone, and Rating.
In a new browser window, insert
todo-in front of the URL for your Fuse Online environment. For example:
Your Fuse Online environment provides the To Do app, which has a REST API for accessing a database that contains tasks. In the AMQ to REST API sample integration tutorial, there are instructions for uploading an OpenAPI document for the To Do app to create an API client connector.
- In the To Do App display, you should see a notification that a new lead was created in the database.
Optionally, view the integration log to troubleshoot an unexpected result or to learn more about integration execution:
- In Fuse Online, in the left panel, click Integrations.
- View your Salesforce to database integration.
- In the integration’s summary page, click the Activity tab.
- Click the integration execution for which you want to view activity information.
3.5. Cleaning up your integration
When you are done working with a sample integration, you should stop it and delete it so that you can use the resources for another integration.
- You are finished working with a sample integration that you published.
- In Fuse Online, in the left panel, click Integrations.
- In the main panel, identify the entry for the sample integration that you want to stop.
- In that entry, to the right, click and then click Stop.
- Click Stop to confirm that you want to stop running the integration.
- In the entry for the integration that you just stopped, to the right, click and then click Delete.
- Click Delete to confirm that you want to delete the integration.