This patch adds support for creating batch updates of modified Drupal object that are pushed to Salesforce when cron runs. When a Drupal object mapped to Salesforce using the 'Automatically Populate Salesforce' option is exported (either when it is created or updated) an additional check for the admin settings is made to determine whether the export should be made either immediately (existing functionality) or at the next cron run, in which case a log entry is made in a new db table 'salesforce_log'. When cron runs all queued updates in this log table are retrieved and the relevant export function is called.
The patch also provides an option to specify a limit on the number of times Drupal will reattempt a failed export, useful if for some reason the data between Drupal / Salesforce becomes deleted or corrupted. The salesforce_log table has an 'attempts' field that is incremented each time an export fails to complete successfully. The cron run will only try to export the queued items that have an attempts field that is less than the admin setting.
NB: the new database table schema has been added to the .install file as an update SO MAKE SURE YOU RUN UPDATE.PHP AFTER INSTALL
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | salesforce_api.549308.patch | 18.42 KB | andybrace |
Comments
Comment #1
andybrace commentedPatch attached, needs to be run from the MODULES ROOT DIR, use the "patch -p0 < salesforce_api.549308.patch" to apply without having to specify filepaths.
Comment #2
andybrace commentedComment #3
aaronbaumanThis is a great idea, but this patch fails to apply to latest version of salesforce_api.admin.inc from dev.
Are there other patches upon which this depends?
Also: for me this bring up a larger issue which is how can we further abstract the sf_node and sf_user functions related to CRUD.
For example, sf_user_export/sf_node_export, sf_user_import/sf_node_import -- these function pairs are almost identical, save one or two idiosyncrasies of saving users vs saving nodes. Openbook's patch implements 2 more function pairs sf_user_pre_export/sf_node_pre_export and sf_user_cron/sf_node_cron.
Two function pairs are easy enough to manage now, but what happens when developers want to add support for other drupal objects - Ubercart orders or vocabularies for example.
This ticket is perhaps not the best place for such a discussion, and maybe we just want to get a stable release out the door before such a drastic refactoring. Anyway, I think it's worth considering as we move forward and this patch highlights the need like a sore thumb.
Comment #4
EvanDonovan commentedGreat question, Aaron - I was just wondering this myself. The Ubercart/Salesforce Integration module has a lot of nearly-duplicate export code right now...but I don't know a way to fix this with the current API.
Still, you may be right about just postponing this until a 2.x stable. Then would a refactoring happen in a 3.x-dev branch? (Maybe that could be the time to switch from Enterprise to Partner WSDL, as well.)
Comment #5
EvanDonovan commentedSeems like this should be postponed on #1018674: Implement entity schema for 6.x-2.x branch, in light of #3.
Comment #6
kostajh commented