Salesforce Drupal Integration

Tutorial to integrate Drupal with Salesforce platform using Salesforce Suite module.

STEP1: Pre-requisites -  In Salesforce.com

1. You need a Salesforce account. Developers can register here.

2. You will need to create a remote application/connected app for authorization. To do the same, in Salesforce go to Your Name > Setup > Create > Apps then create a new Connected App. (Depending on your Salesforce instance, you may need to go to Your Name > Setup > Develop > Remote Access.

3. Set the callback URL to: https:///salesforce/oauth_callback (SSL is mandatory. You can use OpenSSL. Configuration details at OpenSSL.org.)

4. Select at least "Perform requests on your behalf at any time" for OAuth Scope as well as the appropriate other scopes for your application. Additional information.

STEP2: Pre-requisites - in your Drupal site

1. Your site needs to be SSL enabled to authorize the remote application using OAUTH.

2. If using the SOAP API, PHP must be compiled with SOAP web services and OpenSSL support.
Required Force.com PHP Toolkit. The Force.com PHP Toolkit provides an easy-to-use wrapper for the Force.com Web Services SOAP API, presenting SOAP client implementations for both the enterprise and partner WSDLs. You can download the library from GitHub. Refer the getting started guide from developerforce

3. Download and enable drupal Salesforce Suite module. (This module required Entity API and Libraries, only for SOAP API)

STEP3: Authorize your site with Salesforce - Intergrate your site with Salesforce.

1. Open configuration page of Salesforce API at: /admin/config/salesforce

2. Click on Authorize. It will redirect to the authorization page. In this page you have to specify the 'Salesforce Consumer Key'and 'Salesforce consumer secret' which generated for your connected app in Salesforce. You can view this key in your Connected App section in Salesforce (Refer both screen shots)

Authorize page

Salesforce ConnectedApp Settings page  

3. Click on Authorize to authorize your site with Salesforce. It will redirect to Salesforce website and redirect to your callback URL specified in your connected app.

Note: If your site url contains language prefix - please check Issue on "Language prefix breaks authorization" to configure multilingual sites integrating with Salesforce.

STEP4: Map Drupal Entities with Salesforce Objects.
eg. We have a content type called SFUsers and we want to map with Salesforce Contact object

1. Open the Salesforce Mapping Configuration page at: admin/structure/salesforce/mappings.

2. Click on ‘Add Sales force Mapping’. It will open the Add mapping page.  

a. Specify salesforce mapping name in ‘Label’ field

b. Select the Entity type. In our case select ‘Content’. In Drupal entity bundle field will load all the content types.

c. Select the Drupal Entity Bundle. In our case select ‘SFUsers’

d. Select the Salesforce Object. In our case ‘Contact’

e. In the ‘Field Map’ grid we have to map the ‘SFUser’ content type field with the Salesforce Contact object field.

3. You can map multiple fields by clicking ‘Add another field mapping’

4. Action triggers: Here you have to specify the event when or where the action has to triggered. 
ADDITIONALLY NOTE: for high traffic sites, this module provides for asynchronous mode, Select the option ‘Process asynchronously’ to push the data to Salesforce only on Cron run.

After that you can try to add a new content for the content type SFUsers. See the magic. The content added in the drupal can be viewed in salesforce contacts.