Allow salesforce to initiate imports

couzinhub - June 23, 2009 - 18:18
Project:Salesforce
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:aaronbauman
Status:needs review
Description

Not really sure if this is possible already or not, but I'd like to know if there is a way to have a Salesforce to Drupal automatic update.

So far I can create content, like Lead on Drupal, and push it to Salesforce - Awesome
But If I create a Lead directly from Salesforce, how could I have Drupal updated with this new lead ?

I tried to find documentation on this and couldn't. Thanks for your help.

#1

aaronbauman - June 23, 2009 - 21:32

The way I've accomplished this in the past involves Salesforce outbound messaging and Drupal hook_xmlrpc.*

For a good primer on SF Outbound Messaging, I suggest Mike Simmond's blog, specifically this thread -- make sure to read the whole thing because there are several revisions of the code sample.

In a nutshell, you need to setup outbound messaging via the Salesforce web gui and direct it to your drupal install at e.g. http://example.com/xmlrpc.php . Then tweak the sample code into your own module's hook_xmlrpc and you're rolling.

It might take you a while to refine everything to work with your specific use case.

I happen to be working on an sf_xmlrpc module that uses your salesforce.module's field maps to automate the synchronization from Salesforce to Drupal, but it's not quite ready for prime time. I'll try to get a version of that up soon...

* I should mention that an alternative route would be to set up a polling function (ie. a hook_cron) in Drupal to ask Salesforce every so often if it has any updates. Some Drupal developers will prefer this method because it can be administered solely through Drupal. However, this method imho introduces unnecessary complications like race conditions and consistency issues that you can mostly avoid by using outbound messaging.

#2

aaronbauman - June 23, 2009 - 21:47
Assigned to:Anonymous» aaronbauman
Status:active» needs review

Here's the module i've got so far.
I'm using it on 2 development sites so far, and have had no issues.

If you've never used it before, Salesforce outbound messaging can be the hardest part to set up.

You need to set up the Outbound Message, then set up a Workflow to actually fire the outbound message...
I don't remember where i found the tutorial, so dig around a bit if you can't figure it out right away.

Let me know how you fare.


DON'T USE THIS ONE. USE THE NEXT ONE.

AttachmentSize
sf_rpc.tgz 2.68 KB

#3

aaronbauman - June 23, 2009 - 21:46

Sorry - there were some extraneous debugging calls that will probably break that last upload for you.
Use this one

AttachmentSize
sf_rpc.tgz 2.64 KB

#4

Bevan - July 31, 2009 - 05:29
Category:support request» feature request
Priority:normal» critical

Bump: Awesome feature! More testing and review is needed before this can go in SF core though.

#5

Bevan - July 31, 2009 - 05:36
Title:Update Drupal on Salesforce content creation» Allow salesforce to initiate imports

#6

aaronbauman - September 4, 2009 - 18:23

Minor updates, including multiple fieldmaps per salesforce object, further documentation.

AttachmentSize
sf_rpc.tgz 3.29 KB

#7

vfilby - October 22, 2009 - 16:30

I had problems using the above module so I updated the code and rolled a patch (and a tgz). Main changes are:

- Changed fieldmap load so that they didn't try to load based on a range. If the next field map was 4 it would try to load fieldmaps 1 through 3, but if you had deleted fieldmap 2 it would error out.
- Updated the code to use the salesforce_object_map table, rather than salesforce_ids which doesn't seem to exist.
- Changed the data reading to use stream_get_contents rather than a while loop.
- referenced SforcePartnerClient to access SObjects, was erroring out when tyring to create new SObjects without the reference.
- Fixed minor bugs confusing the $info and $map in the update section.
- Converted tabs to 2 spaces for sanity while editing.

sf_rpc module I was using was the 2009/09/04 version above and the patch is based on this version.
salesforce_api version was from 2009/09/01.

AttachmentSize
sf_rpc-20091022.patch 6.67 KB
sf_rpc-20091022.tar_.gz 3.46 KB
 
 

Drupal is a registered trademark of Dries Buytaert.