Allow syncing on update and create
Bevan - July 31, 2009 - 05:41
| Project: | Salesforce |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
An admin might want to specify that a drupal object type be synced on create, but not update, both, or not at all. Change the sync automatically checkbox to a set of three radios to handle these cases, and add/update sf_node_nodeapi() and sf_user_user() respectively.

#1
#2
I think two checkboxes might be more flexible over the long run than three radio buttons. Is there a reason to use radio buttons over multiple checkboxes?
#3
Two checkboxes provides 4 possible combinations, one of which is invalid/undesirable. 3 radio buttons provides less options and is easier to read/understand.
#4
Patch with radio buttons attached.
This builds upon "fix.automatic.patch" from #507638: Node exported on node-add even if automatic export is disabled, and "salesforce_api-fieldmap-checkbox.diff" from #536292: Automatic syncing can not be changed after fieldmap-creation.
I'm a little wary of doing an extra database call on node-update, for performance / efficiency. Since it's followed by a salesforce-synchronization, the db-check is probably not too significant. However, it appeared to be the most clean solution.
#5
Does that mean it requires those patches to be applied first? Includes those patches? Something else?
#6
It requires those patches to be applied first.
If it is desired, I could create the patch where it integrates those other two, and just have one bigger patch. That might take a little time, though. Just let me know what is preferred.
#7
Bevan:
Why is "sync on update only" invalid / undesirable?
I can imagine a situation in which a site should sync only nodes which have been imported manually.
I can also imagine a situation in which a site should sync only on insert.
I agree with bibeksahu that this should be 2 checkboxes or at least 4 radio buttons.
Just to clarify, here are the 4 possible states:
#8
> I can imagine a situation in which a site should sync only nodes which have been imported manually.
This seems very much an edge case to me. Most of the time they will need a manual update-sync callback if they have a manual insert-sync function. And if not, since the user will need to write custom code anyway, they can just disable sync on create in code.
If there are valid AND common reasons to have all four settings this is fine, but I can't see any yet.
#9
OK, point taken - it would make more sense if there were a manual insert function, e.g. on node/%/salesforce or user/%/salesforce. I have a patch on my work machine that I'll upload tomorrow.
#10
I believe that feature already exists, doesn't it? If not, it's a usability bug, and the patch would be welcome.
#11
Oh right, it does already exist -- I maintain that all 4 options should be available.
I don't see how "synch on update only" is any more an edge case than "synch on insert only".
Consider these highly plausible hypotheticals for "synch on update only":
-- A site membership-based site offers limited access to free accounts and extra privileges for approved accounts. Administrators wish only to track member accounts in Salesforce. After administrators manually approve a user's membership, only then should the record be automatically synched.
-- An admin for a highly trafficked community site with open registration wishes to track a select group of users in salesforce -- say "high value users". When the site admin makes a subjective assessment that the user is of high value, the admin exports the user manually. Subsequent updates are synched to salesforce.
Further, even if "synch on update only" were an edge case, the software should not artificially inhibit functionality because the developers didn't think it would be useful, or thought it would be too confusing. Any administrator savvy enough to configure a salesforce synchronization should also be savvy enough to distinguish between 4 synch options rather than 3.
Finally, given a large enough user base for salesforce module, an "edge case" may apply to hundreds or thousands of users (wishful thinking perhaps, but still...)
To this end, this patch builds on bibeksahu's efforts by offering all 4 options with informative #description properties for each.
This patch also switches the values for synch mode to constants, rather than inline integers.
Requires the following patches:
#507638: Node exported on node-add even if automatic export is disabled
#536292: Automatic syncing can not be changed after fieldmap-creation
#12
It's also possible that an administrator might want one fieldmap for create, but another fieldmap for update. E.g., if I want some information to be added upon user creation, but only a subset of that information to be automatically updated.
#13
From #11;
A "synch on update only" setting would break in both these cases because when user accounts are edited that are 1) not approved, or 2) not in the special group, they will get exported to Salesforce – which would leave a data set in Salesforce that is inconsistent with the models from your examples. To create and maintain these data models consistently custom code is required in both cases.
I still don't agree that the fourth setting makes enough sense to go into the UI. Having it would be a (minor) usability bug in my opinion. Perhaps it makes sense for there to be a hidden setting or configuration for this that is not available through the UI but is available for custom modules and drupal code developers?
Either way this isn't a significant enough issue to stop this patch from going in. Patch still needs review.
#12; What would be a use-case for wanting only to synchronise a subset of the data?