I have brewed a lightweight module that uses your site's existing salesforce_api fieldset mappings, drupal batch api, and a simple node_save to run mass imports of your SalesForce data.
Features:
- Updates existing data based on SalesForce Id, if it exists, rather than duplicating.
- Accepts additional "Where" clause for imports, in case you want to import only a subset of SalesForce records.
Is anyone interested in this? If so, I'll clean it up and upload it.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 465962-importlinkfix.patch | 2.62 KB | dpearcefl |
| #30 | sf_import.tar_.gz | 2.96 KB | emptyvoid |
| #28 | sf_import.tar_.gz | 2.58 KB | emptyvoid |
| #25 | 0001-fieldmap-line-193.patch | 801 bytes | iamjon |
| #18 | error.PNG | 19.55 KB | g-me |
Comments
Comment #1
jayboodhun commentedHi
I would like to evaluate your module. I will be working on salesforce Drupal integrationin an upcoming project. Will be good to have this handy.
Many thanks
Jay
Comment #2
jthaxton commentedI think this would also be useful for a project we are working on and I'd be glad to help test or whatever is needed.
Comment #3
acronym commentedI think this is a great idea... our current thinking is that salesforce would be the authoritative/master source for data, it makes sense to be able to do this. Having this tool would be great for people who have a salesforce org and want to add drupal and all its benefits as a community/customer front end.
Comment #4
Anonymous (not verified) commentedVERY interested !
Would be awesome to share this !
Comment #5
aaronbaumanThe attached is module will add a "Import" local task to your menu in Admin > Settings > Salesforce.
It works by querying Salesforce and running a Drupal batch job to import your records one by one using an existing salesforce.module field map. Make sure you set up the field mapping for the content you want to import before you try to import it.
You should be able to follow the on-screen prompts after you install the module and figure out what is what, or go to http://example.com/admin/settings/salesforce/import to get started.
<shameless plug>Also, please check out this other contrib for your reviewing pleasure: #500052: Allow salesforce to initiate imports</shameless plug>
Comment #6
Anonymous (not verified) commentedI can't seam to have this working.
I have two content type. One contact, one Lead, they both have a long list of fields, matching Salesforce fields. The fields are mapped on the fieldmap setting page of Salesforce.
I installed the Import module you provided, but when I go to the IMPORT tab, it says that I have no fieldmap defined yet ("You have not yet defined any fieldmaps.")
I find this confusing as I have two fieldmaps listed under the "Fieldmaps" tab.
Am I doing something wrong here ?
Comment #7
Bevan commentedThis is a candidate for inclusion in salesforce API core once it is RTBC.
Comment #8
aaronbaumanThere are a lot of patches floating around, and I'm working on compiling a list of patch dependencies and an update for this feature. It would be nice to get some of the more basic, critical patches RTBC and rolled into HEAD...
Anyway, the most recent error reported in #6 relates to the overhaul of the fieldmaps system - moved from the variables table to drupal cache / salesforce_field_maps table...
Comment #9
aaronbaumanpostponing this awaiting #476978: Implement "Object Setup" Feature
Comment #10
vfilby commentedA patch to update the import to use the overhauled fieldmap system
Comment #11
TimAlsop commentedSurely it is going to waste resources on web server if there are thousands (or tens of thousands) of records to import ? Isn't it better to use the workflow/trigger approach and push data from salesforce when changed in salesforce ? I can see that it might be useful to have a way to perform an initial load of the drupal objects from salesforce, but after this it is better to make the updates to drupal objects event driven - e.g. if a change is made in salesforce, that change needs to be pushed into drupal, and if a change is made in drupal, that change needs to be pushed into salesforce. This would ensure the two are kept in sync and the data transfer and sync would be efficiently using system resources.
Comment #12
aaronbaumanTim: This is my sentiment exactly. I use this mass import feature together with #500052: Allow salesforce to initiate imports. In this way, I batch import all my Salesforce Contacts to create Drupal users for all my Contacts. Whenever a Drupal user or Salesforce Contact is changed, everything gets kept in synch.
Comment #13
aaronbaumanComment #14
trevortwining commentedI've used this and the import works really well on initial import. I need to further sync nodes on update from SF however (only one way, from SF --> Drupal). Looks like #12 helps with that. But this patch works as is, IMO.
Comment #15
Anonymous (not verified) commentedI like this module, and it does work, except that it's only set up to do node imports (not user imports). This is all well and good, but it can be misleading, because you can choose a fieldmap that is for drupal user accounts, and it will happily allow you to choose it, then go make a bunch of nodes for you. :-)
Attached is a patch that will exclude fieldmaps to user accounts.
Comment #16
aaronbaumanMichelle:
Good catch. I use 99% node mappings, so I never even noticed.
I've compiled these patches and made some adjustments to support user-based fieldmap imports, and fixed another bug where sf_import did not find existing matches.
Comment #17
aaronbaumanA fieldmap that maps SF Record Id was breaking sf_import.
Attached is a new version with the following fix:
Comment #18
g-me commentedHello all,
New to drupal so apologies if I am doing something silly.
I have installed this plugin and when importing all looks good until I get the following error:
# Could not find import function sf_Document_import
# Updated node
Please note a few things. I am actually using Open Atrium which as you may or may not know is a quite heavily customised version of Drupal for Intranet use.
What I am essentially wanting to do is sync from Salesforce into Drupal/Open Atrium so that I can make documents availible to users of our intranet without having to log in.
Any help appreciated. If you need more info please just ask.
Many Thanks
Comment #19
aaronbaumanre #18:
what type of mapping are you using for the import?
what other modules do you have installed?
what version of salesforce are you running?
did you follow the instructions in the README for updating versions?
Comment #20
g-me commentedHi Arron, thanks for the quick response.
I have tried 2 mappings. Documents and contacts each with a few simple field mappings just for testing purposes.
Modules installed are simply salesforce module (incluiding sf_user, sf_prematch,sf_node,sf_import & salesforce_api) and ldap auth (which works but I am using Drupal/Open atrium local admin account)
We are running salesforce enterprise
I havent updated versions so havent read the README for them. I will have a look.
Is there a basic mapping I should try first? or limits on the mapping? I have uploaded our wdsl file and have some custom fields.
Many Thanks
Gavin
Comment #21
aaronbaumanGavin,
The reason I asked what kind of mapping and which version of salesforce you're using is that you seem to have a non-standard mapping. SF Import reads the fieldmap's "drupal" property to determine which import function to use. If you're using an sf_node map, this property should be a value like "node_document" or "node_contact" or whatever the machine name of your Drupal node type is.
The fact that sf_import is looking for "sf_Document_import" means one of the following:
If you have access to your SQL database, please post the results of this query:
SELECT fieldmap, drupal, salesforce FROM salesforce_field_mapComment #22
g-me commentedHello Arron
I am using the latest version of sf_import
I am using the latest version of salesforce module (just got this server going yesterday)
Just to confirm the field maps. I went into fieldmaps, match the objects and select the fileds. When saved this field map is availible in the import tab.
Gavin
EDIT: Apologies. I may have wasted your time. It was a problem with field mapping. I have created new fields in Drupal and it appears to work.
Apologies for this.
Comment #23
aaronbaumanGavin,
It seems like somehow you created a fieldmap that mapped a Salesforce Object to a Salesforce Object (Document to Document). This should not be possible. If Salesforce Objects are showing up in the select element for Drupal Objects, that's a separate issue that you should please report!
Comment #24
emptyvoid commentedWhile testing the module I found a mistake.
line 193 $map['index'] should instead be $map['fieldmap']
Comment #25
iamjon commentedI created a patch for the emptyvoid's change.
Comment #26
mstef commentedAnyone have a tar of the latest?
Is this working?
Can the import be set to sync on cron, or at least daily?
Comment #27
iamjon commentedI think this module is awesome and very very useful. I use it all the time on a 6.x-2.0-alpha2 site with no problems.
Yesterday I tried on 6.x-2.x-dev, but with all the new changes it didn't work. Has anyone else tried?
I really think that it should be included in the salesforce module especially if "At its essence, Salesforce module treats SalesForce like a data silo.".
Any thoughts?
Comment #28
emptyvoid commentedSure thing, here is a tar of my current version of this feature. It is currently running against the:
; Information added by drupal.org packaging script on 2010-04-03
version = "6.x-2.x-dev"
core = "6.x"
project = "salesforce"
datestamp = "1270253676"
Release and has no problems, I successfully imported 10,000 records with it.. looking to extend it with module or better yet write a new module sf_sync to trigger an update, compare periodically on cron run. I read a few issue posts about the notion of queuing transactions. I think it would be a good idea for performance reasons to limit cron syncs to specific times of the day (1am - 5am) and only run syncs on low load times. I guess technically you could setup a slave server to asyncronously issue create, update, and deletes to a dedicated database server and off load the sync so it isn't running on your primary HTTP Drupal instance. Anyway here is my current version of the import module, thanks to @aaronbauman for the original source.
Comment #29
emptyvoid commentedAfter further investigation I just realized that the import as the name implies only imports business objects from Salesforce into Drupal as nodes. The import doesn't map a bridge between the imported nodes and the matching business object in Salesforce.
After a little research I have determined that the "map bridge" is created in the following table "salesforce_object_map", so I am going to work on extending the import module to optionally enable the setup of the "mapping bridge" during the one time import.
My use cases is running a one time import of (say 10,000 account business objects) but I want the nodes in Drupal to be bridged to the Account objects in Salesforce) so if a field value is updated in Drupal I'd like it to already know that the node is bridged to a object in salseforce and push the update (more on that later with the sf_sync module).
Similarly if you create node reference CCK fields to associate content types like account and contact or account and recordType the current import process checks if a "node map" exists (but how would it if you never created the map on import?) So when importing an account you (currently) will never get the recordType value to associate to your imported record type nodes. :( Sure I could manually add the mapping for 3-20 records, but as my example implies as would go mad having to enter 10,000 mappings by hand.. ack!
Pretty sweet once I get the GUI and methods extended then I'll provide a working version here. This will definitely be useful with the sf_sync module I plan to write next week. I'll post my notes and a .gz of my current code as I make progress.
Comment #30
emptyvoid commentedI have attached an updated version of the sf_import module this update fixes several errors that were generated in the code. Also as my previous post states, #29 when importing the system will not link the node to the Salesforce business object unless when defining the field map you check the "automate" option. By checking the "automate" option for a Drupal/Salesforce business object it directs Drupal to push new nodes into Salesforce and send updates from Drupal into salesforce automatically. There may be cases where you want to import the nodes into Drupal and link each to an object in Salesforce, but don't want the nodes to force an update to Salesforce.
I have added an additional option to "link" nodes to the associated business object without having to enable the "automate" option within field mappings.
Comment #31
aaronbauman#30 committed to dev with minor compatibility revisions, updates to README.txt, and adding MODULES.txt file
http://drupal.org/cvs?commit=458878
Thanks for everyone's work on this, I think it's a great addition to the suite
Comment #33
501cGeek commentedPardon my ignorance, I'm interested in trying this out, where can I find the latest version of the module?
Cheers,
Daniel
Comment #34
dpearcefl commentedI don't see that this fix made it into the dev code. Specifically that part where if none of the automatic settings are selected but "Link" on the mass import page is selected that no links are created.
Comment #35
dpearcefl commentedIt looks like the function call to salesforce_api_id_save() was moved from sf_import.module into sf_user.module and sf_node.module. Because $extra array (which contains the extra-linked field value) is not passed to sf_node_import() and sf_user_import(), the value of the "Link" field on the import form is not respected.
We could do one of the following:
I vote for #2. Either way I can do a patch quickly.
Comment #36
kostajh commentedI think an $options array is a good idea for now, if you can put together a patch that would be great!
Comment #37
dpearcefl commentedAttached is a tested patch to allow the node and user "Link" checkbox to work during a mass import.
Comment #38
kostajh commentedThank you for this - committed: http://drupalcode.org/project/salesforce.git/commit/bf8dd68