Skip to Content

Send changed Salesforce object records to a database via Salesforce workflow rule using Jitterbit Integration Studio and API Manager

Introduction

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

Note

Configure an outbound Salesforce message with an API Manager API is a similar integration design pattern that uses Design Studio. Send changed Salesforce object records to a database via Salesforce flow and API Manager is an identical integration pattern that uses a Salesforce Flow instead of a Workflow Rule.

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

  • Part 1: In Salesforce, set up a workflow rule to send an outbound message when an object changes, and download the WSDL file that defines the message.
  • Part 2: In Integration 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 update the outbound message's endpoint URL, activate the outbound message, then test the completed integration design pattern.

Part 1: Salesforce workflow rule and WSDL file

  1. In Salesforce, select Setup > Platform Tools > Process Automation > Workflow Rules.
  2. On the Workflow Rules page, click the New Rule button (highlighted in the image below). If a Try It in Flow Builder dialog opens, click Continue with Workflow Rules.

    Workflow rule 1

  3. On the New Workflow Rule page, click the Object menu, select Account, then click Next.

    Workflow rule 3

  4. On the Account page, enter values for the following, then click Save & Next:

    • Rule Name: Your choice of name.
    • Description: (Optional) A description for this rule.
    • Evaluation Criteria: Created, and Every Time It's Edited.
    • Rule Criteria: Click Run This Rule If the, then select Formula Evaluates to True.
    • In the formula field, enter true.

    Workflow rule 4

  5. On the Edit Rule page, click Add Workflow Action, then select New Outbound Message (highlighted in the image below).

    Workflow rule 5

  6. 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.

    Workflow rule 6

  7. On the Edit Rule page, click Done.

    Workflow rule 7

  8. On the Workflow Rule page, in the Immediate Workflow Actions section, click the description link for the outbound message (highlighted in the image below).

    Workflow rule 7a

  9. 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).

    Workflow rule 8

  10. 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.

Part 2: Integration Studio operations

Define the 'Salesforce Outbound Message' operation

  1. Create a new Integration 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 Integration 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.

    API

  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 Integration 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.

    API

  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

  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.

    Workflow rule

  4. In the Workflow Rules Using This Outbound Message section, click Activate for the rule (highlighted in the image below).

    Workflow rule

Test the integration

To test this integration design pattern, follow these steps:

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