Adding data to Google Sheets when a new lead is added to Salesforce

Learn how easy it is to use App Connect to connect Salesforce to Google Sheets so that every time a new lead is added in Salesforce, details of that lead are added automatically to a row in a Google Sheets spreadsheet.

First, find or create everything you need:

  • An App Connect subscription
  • (If you haven't already connected App Connect to your Salesforce account) The name and password of your Salesforce account.

    If you want to create a free test account in Salesforce rather than use your business account, make sure that you register for a Developer account from this URL: https://developer.salesforce.com rather than a Trial account. If you connect to App Connect with a Trial account, the Salesforce events don't work.

  • (If you haven't already connected App Connect to your Google Sheets account) To connect IBM App Connect to Google Sheets, you use basic auth with OAuth credentials. You need to provide an OAuth 2.0 client ID, client secret, access token, and refresh token with appropriately-selected scopes for Google APIs. Getting those OAuth credentials is described in Getting OAuth client ID, client secret, access token, and refresh token for Google applications.
  • A Google Sheets spreadsheet where the first row contains the following column names:
    • Company name
    • First name
    • Last name
    • Email
    • Source

Next, create your flow:

Using the IBM App Connect Designer authoring experience, you can create your flow from a template, or from scratch if you want to explore the steps taken to create a flow.

As this is a basic example, there is no template in IBM App Connect. Use the following steps in App Connect Designer to create the flow from scratch:

  1. From the Dashboard, click New > Event-driven flow.
  2. 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.
    1. Enter a name that identifies the purpose of your flow; for example: Add row for new lead.
    2. Select Salesforce as your first application (source).
    3. Select New lead as the Salesforce event that will trigger the action in Google sheets.
    4. If you haven't already connected a Salesforce account, click Connect and follow the instructions to allow App Connect to connect to your Salesforce account.
    5. Select Google Sheets as your second application (target).
    6. Select Create row as the Google Sheets action.
    7. If you haven't already connected a Google sheets account, click Connect and follow the instructions to allow App Connect to connect to your Google Sheets account.
    8. Complete the following steps to choose the data that you want to transfer from Salesforce to Google Sheets:
      1. Select the Google Sheets spreadsheet (and then the worksheet) that you configured with the column headings.
      2. For each field that you want to populate, click the Insert a mapping icon , then select the Salesforce field that contains the data that you want to transfer to Google Sheets.
        Figure 1. Example of mapping from Salesforce fields into Google Sheets fields
        Example of mapping from Salesforce fields into Google Sheets fields
  3. Click Start flow on the toolbar, 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 lead in Salesforce.

Finally, test your flow:

  1. Log in to Salesforce with the account that you configured in App Connect, then create a new lead.
  2. Add values for Company, First name, Last name, and Email, then save the record.
  3. Log in to Google Sheets with the account that you configured in App Connect. You should see a new row in your spreadsheet, and the row should contain the details of the new lead that you entered in Salesforce.

Conclusion

You've created a flow that automatically adds details of a lead to a row in a Google Sheets spreadsheet every time a new lead is added in Salesforce.