You are here

Drupal 7 and Salesforce

Submitted by Will on June 1, 2012 - 7:49pm

My colleague Kate recently integrated our site with Salesforce, the increasingly popular cloud-based CRM. Our site here is a Drupal 7 site; Drupal is the most popular CMS on the internet, so it's only natural to want to bring the two together. Here's some notes from Kate about how that worked out for us:

Drupal 7 and SalesForce work nicely together with node types. However, they don't work so well with webforms or contact forms. To integrate Salesforce with our site, I started out making a content type of Contact that sends user information to SalesForce. Keep in mind that you will need to properly configure permissions for a contact form to be effective.

The integration works by mapping Salesforce Objects with Drupal CCK fields. The easiest way to do this is by creating a new content type with some custom fields that you want to add into Salesforce. Here, Kate made content type called "Contact" which allows users to create new "Contact" nodes with a certain set of custom fields.

Install SalesForce Suite. For this example, I enabled Salesforce API and Salesforce Entitiy. Configure Salesforce here: /admin/config/salesforce. Read any errors you get to figure out what you need to configure, upload etc.

Salesforce Suite can at first seem kind of complicated to install, but luckily they guide you through it as you go.

You’ll have to upload the WSDL from whatever account you’d like to use. In Salesforce, you’ll click on your user name in the upper right hand corner and then go to Setup > Develop > API > Generate Enterprise WSDL and click Generate. You’ll get some ugly code (at least if you’re in Firefox), but just Save Page As… and leave it as whatever .xml file you get. Upload in Drupal here: /admin/config/salesforce/wsdl

Salesforce uses wsdls, and Salesforce Suite allows you to add your own. They do have a default one to use, but it's highly advisable to upload one from your account.

Once everything is configured and all of the angry red errors are gone (I left one about AES Encryption, but you might want to install that module), go to the Object Setup tab (/admin/config/salesforce/object) and make sure the Salesforce object you want to work with is checked. Then go to the Fieldmaps tab (/admin/config/salesforce/fieldmap) and click Add and select your Drupal node type and Salesforce object. Name it! Hit Map object fields! This is thrilling!

Kate can sometimes get a little excited about working with Drupal. And no wonder, this is some mighty useful stuff.

The first half of this form is pretty self-explanatory. Use the Map A Salesforce Field menu to Add fields from Salesforce and then select the corresponding Drupal field. Save your changes. This part is done.

And voila! You're Drupal site is now integrated with Salesforce. But, say you want to emulate a webform where results are mailed to admins and the users who filled them out. Well Kate's got that covered too.

Now we want to make sure that people are notified when a new node. Install (or enable) the Rules module and go to the configuration page for that module (admin/config/workflow/rules). Add a new rule and set React on event (for this example, I used Node: After saving new content). On the next page, you can add conditions (that the node is a certain type, etc), and actions (Send mail). I used some replacement patterns to populate the emails and make it nice to read. I found that I got some strange errors until I set the Language value as English (click the Switch to the direct input mode button first).

Hope that helps! Be sure to run some tests to make sure all of the parts of your process are working.

As you can see, Kate's a master at this stuff. She got Salesforce integrated with our site and made it so it acts just like a webform. And now, thanks to her help, you can too!

If you have any comments or corrections or whatnot, be sure to add those below.