Skip to Content

Send Changed Salesforce Object Records to a Database via Salesforce Flow and API Manager

Introduction

This integration design pattern sets up a Salesforce flow that sends an outbound message to an API Manager API when an object changes (in this example, the Account object). A Cloud Studio project processes the Salesforce outbound message, maps the object's data, and saves it to a database.

Note

Send Changed Salesforce Object Records to a Database via API Manager is an identical integration pattern that uses a Salesforce Workflow Rule instead of a Flow.

To set up this pattern, follow these sections in order:

  • Part 1: In Salesforce, set up an outbound message and a flow to call it when an object changes, and download the WSDL file that defines the message.
  • Part 2: In Cloud Studio, set up an operation chain to receive the Salesforce outbound message, and store the mapped values in a database.
  • Part 3: In API Manager, set up an API as an endpoint for Salesforce.
  • Part 4: Return to Salesforce to activate the flow, then test the completed integration design pattern.

Part 1: Salesforce Flow and WSDL File

  1. In Salesforce, select Setup > Platform Tools > Process Automation > Workflow Actions > Outbound Messages.
  2. Click the New Outbound Message button (highlighted in the image below).

    Part 1.1

  3. On the New Outbound Message page, click the Object menu, select Account, then click Next.

    Part 1.2

  4. On the New Outbound Message page, enter values for the following, then click Save:

    • Name: Your choice of name.
    • Unique Name: This name is automatically generated based on the value for Name and the field's naming rules.
    • Description: (Optional) A description for this outbound message.
    • Endpoint URL: example.com. This temporary URL is updated later.
    • User to Send As: Enter the user that sends the outbound message. The value defaults to your Salesforce username.
    • Protected Component: Not selected.
    • Send Session ID: Not selected.
    • Account Fields to Send: Select the object fields to send. In this example, only Name and Phone are selected. The Id field is selected automatically, because it is the key field for the object.

    Part 1.3

  5. In the message's Workflow Outbound Message Detail page, click the link Click for WSDL in the row labeled Endpoint WSDL (highlighted in the image below).

    Part 1.4

  6. An XML file opens in a new browser window. Save the file with a .wsdl extension. Depending on your operating system, you may have to set the file's extension after downloading.

  7. In the Salesforce browser window, select Setup > Platform Tools > Process Automation > Flows.

  8. On the Flows page, click the New Flow button (highlighted in the image below).

    Part 1.5

  9. In the Flow Builder's New Flow dialog, select the Core tab, select Record-Triggered Flow, then click Create.

    Part 1.6

  10. In the Configure Start dialog, enter values for the following, then click Done:

    • Select Object: In the Object field, enter Account.
    • Configure Trigger: For Trigger the Flow When, select A Record Is Created or Updated.
    • Set Entry Conditions: For Condition Requirements, leave the value as None.
    • Optimize the Flow For: Select Actions and Related Records.

    Part 1.7

  11. On the Flow Builder page, hover on the node between Start and End (indicated by a red arrow in the image below), then click Add Element.

    Part 1.8

  12. In the Add Element dialog, select Action.

    Part 1.9

  13. In the New Action dialog, select the Outbound Message category.

    Part 1.9

  14. Click the Action search bar, then select your outbound message. Enter values for the following, then click Done:

    • Label: Enter a label for the action.
    • API Name: This name is automatically generated based on the value for Label and the field's naming rules.
    • Description: (Optional) Enter a description for this action.

    Part 1.9

  15. On the Flow Builder page, click Save.

    Part 1.9

  16. In the Save the Flow dialog, enter values for the following, then click Save:

    • Flow Label: Enter a label for the flow.
    • Flow API Name: This name is automatically generated based on the value for Flow Label and the field's naming rules.
    • Description: (Optional) Enter a description for this flow.

    Part 1.9

Part 2: Cloud Studio Operations

Define the 'Salesforce Outbound Message' Operation

  1. Create a new Cloud Studio project.

  2. Drag a SOAP Request activity from the design component palette and drop it onto an empty operation in the design canvas.

  3. Set the operation name to Salesforce Outbound Message.
  4. Double-click the SOAP Request activity instance in the operation to open its configuration screen.
  5. In step 1, select Upload File, click Browse, select the WSDL file previously downloaded, then click Upload.
  6. Click Port and select Notification (the only option). The remaining fields are automatically filled and need no further editing.
  7. Click Next.

    Operation

  8. In step 2, click Finished.

    Operation

  9. Add a new transformation to the right of the SOAP Request activity.

  10. For the target schema, click Mirror Source Schema.
  11. Click Automap Exact Matches, or manually map source to target fields.
  12. In the target schema, click Edit Schema, set the schema name to Upsert Schema, then click Save Changes.

    Operation

  13. Close the transformation to return to the workflow.

    Operation

  14. In the component palette's Connectors category, find and click the Variable connector.

  15. Leave the connection and variable names with their defaults, then click Save Changes.
  16. Drag a Variable Write activity from the component palette and drop it onto the Salesforce Outbound Message operation, to the right of the transformation.
  17. Double-click the Write activity.
  18. In step 1, select Yes, Use Saved Schema, click Saved Schemas, select Upsert Schema, then click Next.

    Operation

  19. In step 2, click Finished.

    Operation

    The Salesforce Outbound Message operation:

    Salesforce Outbound Message

Define the 'Salesforce Response' Operation

  1. Drag a SOAP Response activity from the component palette and drop it onto an empty operation in the design canvas.
  2. Set the operation name to Salesforce Response.
  3. Double-click the SOAP Response activity.
  4. In step 1, select Select Existing, select the WSDL file previously uploaded, then click Next.

    Operation

  5. In step 2, click Finished.

    Operation

  6. Add a new transformation to the left of the SOAP Response activity in the Salesforce Response operation.

  7. Add a custom value to the Ack field with the value true, then close the transformation to return to the workflow.

    Operation

    The Salesforce Response operation:

    Operation

Define the 'Database Upsert' Operation

  1. Drag a Variable Read activity from the component palette and drop it onto an empty operation in the design canvas.
  2. Set the operation name to Database Upsert.
  3. Double-click the Read activity.
  4. In step 1, select Yes, Use Saved Schema, click Saved Schemas, select Upsert Schema, then click Next.

    Operation

  5. In step 2, click Finished.

    Operation

  6. Set up a Database connection for your target database, then click Save Changes. (A connection to a PostgreSQL server is shown in this example.)

    Operation

  7. Drag a Database Upsert activity from the component palette and drop it onto the Database Upsert operation, to the right of the Read activity.

  8. Double-click the Upsert activity.
  9. In step 1, click Refresh, select the target database table, then click Next.

    Operation

  10. In step 2, select the columns to be updated, then click Next.

    Operation

  11. In step 3, click Finished.

    Operation

  12. In the Database Upsert operation, add a new transformation between the Read and Upsert activities.

  13. Manually map source Salesforce object fields to target database columns, then close the transformation to return to the workflow.

    Operation

    The Database Upsert operation:

    Operation

Operation Actions and Deployment

  1. Open the settings screen for the Salesforce Outbound Message operation.
  2. Select the Actions tab, then set the following field values:
    • Condition: On Success.
    • Action: Run Operation.
    • Operation: Salesforce Response.
  3. Click + Add Action, then close the operation settings screen.

    Operation

  4. Open the settings screen for the Salesforce Response operation.

  5. Select the Actions tab, then set the following field values:
    • Condition: On Success.
    • Action: Run Operation.
    • Operation: Database Upsert.
  6. Click + Add Action, then close the operation settings screen.

    Operation

    The completed project, prior to deployment:

    Project

  7. Deploy the project.

Part 3: API Manager API

  1. In API Manager, select My APIs, then click New API.

  2. In step 1 of the Publish New API page, enter values for the following, then click Next:

    • API Name: Enter a name for the API.

    • Environment: Select the environment where the Cloud Studio project was deployed to.

    • Service Root: Leave the initial value derived from the API name.

    • Version Number: (Optional) Enter an API version number.

    • Description: (Optional) Enter a description for this API.

    Part 3.1

  3. In step 2, select Custom API as the Service Type and then click Add API Service. For the new API service, enter these values for the following fields, click Save, and then click Next:

    • Request Method: Use the menu to select the POST request method for the API service. By default, the request method is set to GET.

    • Service Name: Enter a service name.

    • In the Operation tab, select these values:

      • Assign Project: From the menu, select your Cloud Studio project.

      • Assign Operation(s):

        • Operation: Selcect the Salesforce Outbound Message operation.

        • Response Type: Select Final Target as the response type.

    Part 3.2

  4. In step 3, click Skip This Step.

  5. In step 4, click Save & Publish.

    Part 3.3

  6. In the dialog titled All Set, Your API is Live!, click Copy URL, then click Dismiss.

Part 4: Update Salesforce Endpoint URL and Activate Flow

  1. In Salesforce, select Setup > Platform Tools > Process Automation > Workflow Actions > Outbound Messages.
  2. On the Outbound Messages page, click Edit for your outbound message.
  3. Replace the contents of Endpoint URL field (highlighted in the image below) with the URL copied at the end of the previous section, then click Save.

    Part 4.1

  4. Select Setup > Platform Tools > Process Automation > Flows.

  5. Click the flow label for the Jitterbit Flow entry (highlighted in the image below).

    Part 4.2

  6. On the Flow Builder page, click the Activate button (highlighted in the image below).

    Part 4.3

Test the Integration

To test this integration design pattern, follow these steps:

  1. In Salesforce, open the Service app, then select the Accounts tab.
  2. Edit an account contact, then save it.
  3. Log into your database and query the target table.