Integrating Salesforce with Drupal 7

We were recently inspired by Salesforce’s annual “Dreamforce” conference to show how important it is for Drupal websites to integrate with Salesforce. The most common use case for integrating Salesforce with a Drupal site is something like this: Visitors fill out a contact webform on a Drupal website. The data from the form submission is transmitted to Salesforce, where it’s stored as a new record (or "lead" in CRM terms).

The old way to accomplish this integration (before later versions of Drupal 6.x and Drupal 7) was to use Salesforce’s API along with a Salesforce Suite Drupal module. There’s also a Salesforce Webform integration module which extended this integration and makes it easier. After a little research, we found that the modules in this solution are no longer supported in later versions of Drupal 6.x or in Drupal 7.

No more integration with Salesforce right? WRONG. Drupal is all about custom modules. Instead of waiting for someone to support those modules, you can follow a few simple steps to accomplish the integration:

  1. Log into Salesforce and create a Web-to-Lead form.
  2. Recreate a form with the same fields in Drupal using the Drupal Webforms module.
  3. Add a hidden field to the webform called 'oid', with a value that matches the hidden oid field that should be present in the Web-to-Lead form you created.
  4. Create a custom module that implements hook_webform_submission_insert(), posting the webform data to Salesforce the exact same way the Web-to-Lead form does (after the webform data has been validated and stored on the Drupal side.)

Here’s a good example of what a custom hook_webform_submission_insert() might look like in Drupal 7:

Profile picture for user John Clauss