Closed (fixed)
Project:
Salesforce Suite
Version:
7.x-3.x-dev
Component:
salesforce_pull.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Apr 2013 at 01:16 UTC
Updated:
17 Aug 2018 at 14:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tauno commented#1961760: Add required field to SOQL query for Salesforce Pull has the start to another possible approach - add a condition to the salesforce query.
Comment #2
kostajh commentedI'd prefer to have a hook. I think the approach in #1961760: Add required field to SOQL query for Salesforce Pull has some potential problems.
Might also consider looking at using Rules to configure which entities can be be processed on pull.
Comment #3
levelos commentedComment #4
levelos commentedTauno, bleedev and I were discussing that we could handle this through a hook_salesforce_soql_query_alter() call, which would increase performance and be useful in other cases. Chime in, and we can adjust this ticket accordingly.
Comment #5
bleedev commentedLevelos and I discussed re-working the method being used to get the updated records. Currently salesforce_pull:salesforce_pull_get_updated_records calls the salesforce_get_api()->query method, passing a string for the query. If that method is modified to use an object or array containing the query definition (fields and conditions, etc.), the method could use a hook_salesforce_soql_query_alter() to modify the query definition before it is constructed into a string and processed.
Comment #6
kostajh commentedThat sounds like a good approach to me. Let me know when you have a patch and I'll take a look.
Comment #7
tauno commentedI think this approach would work for my use case just fine. Thinking more abstract, if a mapping applies to multiple objects the hook_salesforce_soql_query_alter will prevent it from being pulled for any of those mappings. At least, this is how I think the pull process works right now.
Comment #8
kostajh commentedJust noting that this approach should also work well with #1969034: Create admin interface for Salesforce Pull - it could allow a UI for adjusting the SOQL query.
Comment #9
tauno commentedComment #10
levelos commentedThe structured SOQL query and a corresponding are now implemented. Ref. http://drupalcode.org/project/salesforce.git/commit/83578cbe00883ee2cc52... and subsequent commits.
Comment #12
gcbI've discovered a use case in which altering the SF query is not adequate: we want to exclude, in this case, contacts with duplicate emails from coming over, so the object needs to be blocked based on a local DB query to Drupal, as we can hardly pass all our existing email addresses over to Salesforce. If only SF had a "email address is unique on salesforce" query option!
Patch attached.
Comment #13
aaronbaumanInstead of
Do this:
Comment #14
gcbWhat is this "php" you speak of?
Re-rolled with suggested change.
Comment #15
aaronbaumanLooks good
Comment #16
tauno commentedLet's change this to hook_salesforce_pull_object_allowed($sf_object, $mapping_object, $mapping) to more closely align with hook_salesforce_push_entity_allowed($entity_type, $entity, $sf_sync_trigger, $mapping).
Comment #17
tauno commentedThere's also #2488820: Create hook_salesforce_pull_entity_allowed that approaches the same problem.
Comment #18
gcbThose are some remarkably similar patches.
Comment #19
yogaf commentedAnother one here: https://www.drupal.org/node/2186153
Comment #20
gcbRe-rolled against 7.x-3.2.
Comment #21
acrosmanThe patch from #20 works nicely. Looking back over the issue the only reason this isn't in the suite was a concern about the hook's name. Given that this issue has been sitting around for a couple years and several folks have code written against it with the current name it seems like makes more sense to move forward as written instead of modifying it at this point. So I'm resetting to RTBC.
Comment #23
aaronbaumanThis is in
Comment #25
bob.hinrichs commentedThe beta dev with this patch broke my site (dedupe field errors), so I am using 7-2.x. I was going to ask if it is possible to use hook_salesforce_pull_entity_presave for this in absence of this change, but now I see it won't stop the processing. It would be easy to backport to 7-2.x but am unsure whether a full 7-3.x will be the next full release. I may do that anyway as this is superior to workarounds.