Learn how to use IBM App Connect on IBM Cloud to create an event-driven flow such that when a new lead is created in Salesforce, if App Connect finds that lead in the IBM Db2 database then it sends an email to the Salesforce lead owner giving them the Db2 history of the lead. This tutorial demonstrates how you can easily create a flow by specifying information in a simple manner.

IBM Db2 is a relational database management system (RDBMS) product that services as a key to solving the problems of information management.

Scenario:

You are a Sales LoB person who has been using Db2 to store details of all your prospects or leads with other customer data. Then you have decided to switch over to Salesforce as your Customer Relationship Management (CRM) system, and started using it to record all new leads.

When a new lead is created in Salesforce, you want the lead owner to be automatically notified if the lead exists in Db2. For this, you use App Connect to easily create an event-driven flow that is triggered when a new lead is created in Salesforce, and checks if the lead is an existing lead in the Db2 leads table, and if the lead does exist so sends an email to lead owner giving them the Db2 history of the lead.

Event-Driven flow to retrieve record from Db2 Table using IBM Db2 database node. (Click image to view full size.)

First, find or create everything you need:

This document assumes that you have signed up for free or trial accounts with Salesforce and IBM Db2 database server, or that you have business accounts.

  1. An App Connect subscription.
  2. Obtain account details for connecting App Connect to your applications (If you haven’t already connected App Connect to your applications.):
    • For Salesforce, you need user ID and password credentials to connect. If you want to create a free Salesforce account to test out App Connect, make sure that you create a Developer account rather than a Trial account. For more information, see How to use IBM App Connect with Salesforce
    • To connect to IBM Db2, you need the Db2 database server host name, port, user ID, password, database name, and schema name. If you are not the owner or administrator of your Db2 instance, you can obtain this information from your Db2 administrator.
      • Db2 host name and port: The Db2 database server host name or IP address, and the port number of the database server listener. Use the following format: hostname:port.

        Tip: The default value of localhost can be used for the host name if the database is running on the same system as the IBM Secure Gateway Client. If using the Db2 default port, 50000 is used for a connection without SSL.

      • Database: The Db2 database name, specified in uppercase.
      • User name: A Db2 database user name, specified in uppercase.
      • Password: The password for the Db2 database user.
      • Schema: The schema qualifier, specified in uppercase, for the collection of database objects you want to perform operations on.
      • Network name: The name of the network (configured using the IBM Secure Gateway Client) for connecting to a Db2 server in a private network.

        Important: Ensure that the Secure Gateway Client has been started. If you need to, you can start the Secure Gateway Client as described in Configuring a private network for App Connect Designer: Finally, start and configure the Secure Gateway Client.

      • Example of completed fields for connecting from App Connect

        These entries relate to a locally-installed Db2 server.

        Example of IBM Db2 connection details

      You can connect to the IBM Db2 app either from the Applications tab on the Catalog page, or when you add the app to a flow. After you connect, the Db2 database objects, and applicable events and actions can be discovered.

      Tip:

      • Immediately after you connect, rename your account with a meaningful name that helps you identify which schema the account relates to. You’ll find this useful if you’d like to access multiple schemas in your flows. You can rename an account only from the Applications tab on the Catalog page, and before it’s used in a flow.
      • If you’d like to access multiple schemas in your flows, you’ll need to add an account for each schema whose objects you want to run operations on.

        For information about renaming accounts and setting up multiple accounts, see FAQ: How do I configure App Connect to connect to my applications?

    • You also need to configure a private network in IBM App Connect, with the IBM Secure Gateway to reach IBM Db2 database server on a private network. If you’ve previously used the Secure Gateway Client to set up a network connection for an App Connect application that is on the same private network as the Db2 server, you can use this network connection with Db2.

      For detailed information about configuring a network connection by using the IBM Secure Gateway Client, see Configuring a private network for App Connect Designer

Next, create your flow:

  1. Log in to App Connect Designer; for example, launch App Connect through your IBM Cloud dashboard.
  2. From the Dashboard, click New > Event-driven flow.

    Complete the following steps. As you progress, App Connect automatically saves your changes. If you navigate away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.

  3. Enter a name that identifies the purpose of your flow; for example: Retrieve lead history from Db2 for each Salesforce lead
  4. Select Salesforce > New lead as the event that is to trigger the flow.
  5. Click the (+) and then scroll down to IBM Db2.
  6. Select IBM Db2 > Show More > Retrieve LEADS records as the action.
    IBM Db2 / Retrieve LEADS record action. (Click image to view full size.)
  7. Map the Retrieve LEADS where clause fields with the response from Salesforce lead object.
    IBM Db2 / Retrieve LEADS records Where Clause Mappings. (Click image to view full size.)
  8. Select the If(Conditional) node from Toolbox and use the count function to check the leads count on the response from Db2 Retrieve node
    IF Condition node with count function to check the leads count on response from Db2 Retrieve node. (Click image to view full size.)
  9. Inside the IF flow node select Salesforce > Retrieve user to get the Lead Owner’s email address and map the User ID with Owner ID from salesforce New Lead response
    Salesforce / Retrieve user node to get lead owner’s email address using lead owner’s id. (Click image to view full size.)
  10. Use Gmail > Create Message to send an email to the lead owner along with the lead’s history
    Gmail / Create Message node to send an email to lead owner’s id with the history of the lead. (Click image to view full size.)
  11. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow. Your flow is displayed on your Dashboard and is listening for your event – the addition of a new contact in Salesforce.
    The flow tile on the Dashboard, showing that the flow is running and listening for events. (Click image to view full size.)

Finally,test your flow:

  1. Log in to Salesforce using the account that you configured in App Connect.
  2. Create a new Salesforce lead that already exists in your Db2 database, and then save the lead.
    Creating a new contact in Salesforce. (Click image to view full size.)
  3. After a short while, check your email inbox for a new email containing the history of the lead obtained from the Db2 database.
    History of the existing lead is fetched from Db2 . (Click image to view full size.)
  4. Examine the App Connect Dashboard. If the flow ran successfully, the flow tile shows a green tick
Flow tile showing the last successful run of the flow. (Click image to view full size.)

Congratulations, you have created a flow that is triggered when a new lead is added to Salesforce, and retrieves the history of that lead from a leads table in IBM Db2, and then sends an email to the Lead owner with lead’s history.

Join The Discussion

Your email address will not be published. Required fields are marked *