As per http://drupal.org/node/507800#comment-1936264 this patch adds a hook to core which gives other modules an opportunity to provide the sfid for an existing salesforce object which matches the drupal object which is being synched (and which is not currently matched to an sfid).

Please see http://drupal.org/node/507800 for more information.

CommentFileSizeAuthor
salesforce_find_match_hook.patch2.68 KBSid_M

Comments

Bevan’s picture

Sid, as per http://drupal.org/node/507800#comment-1873144, please move this part into an implementation of the hook function in salesforce_api.module.

+  $prematch_found = false;
+  if (empty($sfid)) {
+    // call hook_sf_find_match to give opportunity to try to match existing sf object instead
+    // of creating a new one.
+    $matches = module_invoke_all('sf_find_match', 'export', 'node', $node, $map);
+    // TODO: handle case where multiple implementers of hook return multiple results.
+    if (count($matches)) {
+      $sfid = $matches[0];
+      $prematch_found = true;
+    }
+  }

If you're not familiar with how to invoke or implement hooks the Drupal way, let me now and I'll document in more detail.

Bevan’s picture

Status: Needs review » Needs work
aaronbauman’s picture

Status: Needs work » Fixed
aaronbauman’s picture

Also implemented is similar call to salesforce_api_search_for_duplicates on sf_user_import and sf_node_import.
ie. hook_sf_find_match should return nid or uid (etc.) when direction is "import" and salesforce id when direction is "export".

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.