There has been much discussion about how to provide more power and flexibility to when SF synchronization takes place. Whether to do it on create / update / etc.

The Drupal Actions system (new to D6, enhanced in D7) provides support for exactly this, for any actions.

By making "Export to Salesforce" / "Import from Salesforce" available as Actions, we would gain the full power and flexibility of the Drupal Actions system (along with its strong UI), while having to maintain minimal code on the salesforce_api side.

Attached are some modules that do exactly that. "sf_actions" makes the "Export User / Node to Salesforce" actions available. "user_after_update_trigger" makes a trigger available for the "after_update" op of hook_user. (It's not provided by default by trigger.module, presumably as an oversight.) Import is not provided at this time, but should be a fairly-straightforward variation of the export functionality.

It is recommended that if you want to update users through this system, that you enable both modules and use the "After user's profile has COMPLETED updating" trigger, rather than the default user-update trigger, as the default will sync the user's state prior to the update.

These are made available as modules, and do not require any patching of the salesforce_api module (I don't think). They should work fine with most patches.

This code uses the first-found fieldmap for a given type, regardless of whether the "automatic" flag is set or not.

It is recommended that you turn off "automatically synchronize on insert" for your various fieldmaps if you use this. Although this system doesn't care whether that's on or off, it may result in double-synchronization if both are on.

The attached modules are preliminary code, only slightly tested and not yet used in any production environment. But they seem to work okay, thus far.

Comments

aaronbauman’s picture

Status: Active » Needs review

bibeksahu,
Nice work.
I haven't reviewed this at all yet, but in theory it sounds like this will provide a great alternative to the built in functionality.
Thanks for the contrib.

rjacobs’s picture

Yes, I think this is a great idea as it gives very fine-grained control over exactly when various salesforce syncs will take place. Seems like a great way to introduce automatic updating in an elegant way.

So far I have only tried it to do user syncs (on "create", "login" and "After user's profile has COMPLETED updating") and it works great.

Thanks so much also for including the 2nd module to enable the "After user's profile has COMPLETED updating" trigger! If you had not included and explained that I am sure that I would have stumbled around aimlessly for hours wondering why the "update" trigger was not actually leading to my sync taking place when changing user data. Really big thanks for that.

One note, I needed to comment out the two lines that call the dpm() function (about lines 35 and 67) as I don't have the developer module installed. It looks like that function is dependent on that module and is a nonessential function in this context (only used for messaging/logging)?

I'm still just learning Drupal triggers and actions, but it certainly seems like a good way to implement this functionality. I suppose that many people who just need a simple set of options/checkboxes to automatically sync and update will be quite happy with the patch at #536298: Allow syncing on update and create, but for more complex sync timing and customization, this module may be the answer.

Thanks!
Ryan

bibeksahu’s picture

Another, very similar, option would be to use the "Rules" module. It is a more powerful version of Triggers / Actions, and a lot of other modules make use of it (e.g., "og", etc.).

- Bibek

EvanDonovan’s picture

Subscribing. I was just thinking Actions would be useful today.

I discovered that when I create a mapping between a user profile and a Contact record, using sf_user.module, and set to sync on Create/Update/Delete, the user must actually log in to the account before the sync happens. It's as if the user profile data doesn't get saved until the user logs in. (I'm going to try with Content Profile Registration next to see if the node sync is different.)

I am presuming that with actions, I could have the sync happen on hook_user $op == 'register', instead of their first login. (This would account for some cases I can foresee where users will create an account, but then not log in again, yet they should be in Salesforce. This may occur since we are going to be using SF API (and possibly Salesforce Ubercart) to track student registrations and course purchases for our online college.

aaronbauman’s picture

Status: Needs review » Closed (won't fix)

I think this would be a great contrib module, and will be happy to cross-promote on the salesforce module page.

I'm receptive to anyone who wants to make the case for including rolling this into the sf module suite,
but at the moment I'm of the opinion that the suite has already become too large and should be broken into component modules anyway.

For now I will mark this "won't fix" for the reasons above, but please feel to reopen in order to continue discussion.

EvanDonovan’s picture

Status: Closed (won't fix) » Active

As it turns out my comments in #4 were inacccurate. The contact record in Salesforce was getting created right away, after all.

Sorry for reopening this issue - I actually agree with you that this would be better as a contributed module than as part of the core Salesforce suite. The codebase of the basic Salesforce modules is already quite extensive, and probably not easy to maintain, I'm sure.

However, I am reopening this since I am unable to implement the workflow that my boss desires since he wants to make it so that people can register and pay for online courses via Ubercart without being logged in, but the Ubercart/Salesforce Integration module is not doing the proper Opportunity Contact Record data sync since, I believe, the profile data has not yet been saved. If I had Actions integration, then possibly I could do the sync of the Ubercart purchasing data (& Drupal user) on a cron run.

I will take a look at bibeksahu's code, but I imagine that it would take some serious work to get it resynced with the current dev of the Salesforce module.

Aaron, are you ever in Drupal IRC? If so, I'd like to have a chance to chat with you sometime, since I think that I'm going to be working with this module fairly extensively over the next few months, and would like to work on improvements.

Feel free to close this again after you read this message; I just re-opened it so that it would show up for you in your regular queue.

EvanDonovan’s picture

Status: Active » Postponed

I think that I will take the code from this issue & create a separate project for it, although it will probably need to be updated to work with the new version of Salesforce API. Once the project is created, then I will mark this as fixed.

rjacobs’s picture

+1 for the idea of capturing this effort in a separate project. We plan to use this feature on a number of projects, and from our perspective, it would be great to have it as part of the API. However, I think there is a fair case to keep it separate. Regardless, having this functionality as part of a formal Drupal project would be a huge asset.

EvanDonovan’s picture

Assigned: Unassigned » EvanDonovan

At some point, will get around to making this a separate module.

EvanDonovan’s picture

Title: Salesforce_api / Actions integration » Create a module providing Salesforce_api / Actions integration (Needs updating to latest 2.x)
Assigned: EvanDonovan » Unassigned

I haven't needed this yet after all, so unassigning. (Conditional Actions were all that I needed for Ubercart integration.)

If someone else wants to go ahead and make this a module before me, go ahead. It will need to be re-rolled for compatibility with the latest 2.x, which is one of the reasons I haven't done this yet.

rjacobs’s picture

This has also been de-prioritized for our immediate implementation needs (party given that #983192: on user update salesforce is updated with old account data has been addressed in sf_user now), but I still think this is a very useful feature, and can think of several ways we may leverage it in the future.

dpearcefl’s picture

Is there any interest in this functionality still? I have put together a hard-coded version of this request already. I could add a UI to it, but I'd like to hear if others would benefit from it before I do the work.

EvanDonovan’s picture

@dpearceMN: I would not benefit from it in my immediate work, but I think it would be helpful just to post as a sandbox project (no UI needed). Then this issue could finally be closed.

dpearcefl’s picture

StatusFileSize
new4.31 KB
new5.08 KB

Well, I got the go-ahead today from my boss to finish a module that we intend on releasing as a standalone project on drupal.org. I've attached a couple of screenshots of the UI.

The maps listed are drawn from the salesforce_field_map table but this module maintains it's own table. For each map, you will have the following settings:

  • Enable an import action
  • Enable an export action
  • Number of hours between each import (Every time the action is hit, 1, 2, 4, 12 or 24 hours)
  • Number of hours between each export (same as above)

I'll let everyone know when I'm done and the project is posted.

EvanDonovan’s picture

Cool. So is this integrated with Actions/Rules so that you can have an import or export triggered by an arbitrary condition? I think this will be a great resolution for this issue.

dpearcefl’s picture

Yes, it does work with the Trigger core module so imports and exports can be triggered for whatever trigger exists. The module will define advanced triggers. The UI is still in flux and in fact, the "Main admin page" may go away in favor of something else.

Stay tuned.

dpearcefl’s picture

Project submitted for approval a week ago. Waiting on approval.

dpearcefl’s picture

Still waiting on approval. If any one here has the permissions to approve a sandbox project (http://drupal.org/node/1152012), it would be appreciated.

kostajh’s picture

I added a link to Salesforce Actions in the project description. When your project is approved, I'll update the link.

EvanDonovan’s picture

Title: Create a module providing Salesforce_api / Actions integration (Needs updating to latest 2.x) » Review the module providing Salesforce_api / Actions integration (Exists in sandbox)
Issue tags: +7.x-2.x

I'll try to review the module shortly, since we may need this in 7.x-2.x, and I'd like to have it as a real project.

klausi’s picture

Title: Review the module providing Salesforce_api / Actions integration (Exists in sandbox) » Salesforce Actions
Category: feature » task
Status: Postponed » Needs work
Issue tags: -7.x-2.x

* link to the salesforce project from your project page
* Git release branch missing, see http://drupal.org/node/1015226
* lines in README.txt should not exceed 80 characters
* Remove all old CVS $Id tags from your files, not needed anymore
* info file: Remove the "version" property, this is added by drupal.org packaging automatically
* module: @file doc block missing, see http://drupal.org/node/1354#files
* "function salesforce_actions_action_info()": two spaces in the middle
* "'hooks' => array(" the following line should be indented, as this is a sub array
* "print_r($batch_context);" remove debug statements from your code
* salesforce_actions_import_action_form(): indentation in the function body arrays should always be 2 spaces

dpearcefl’s picture

Title: Salesforce Actions » Salesforce Actions (proposed module)
Status: Needs work » Closed (won't fix)

Closing this issue because all comments should be made on the Salesforce Actions module queue itself.
#1152012: Salesforce Actions