You are here

function sf_prematch_sf_find_match in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7 sf_prematch/sf_prematch.module \sf_prematch_sf_find_match()
  2. 7.2 sf_prematch/sf_prematch.module \sf_prematch_sf_find_match()

Implement hook_sf_find_match

Parameters

string $action:

stdClass $object:

array $map:

File

sf_prematch/sf_prematch.module, line 149
Extends Salesforce API module so checks for an existing match for an object before creating a new one.

Code

function sf_prematch_sf_find_match($action, $object_type, $object, $map) {
  if (is_object($map)) {
    $fieldmap_name = $map->name;
  }
  else {
    $fieldmap_name = $map;
  }
  $match_by = sf_prematch_match_by_load($fieldmap_name);
  if ($match_by['primary_field'] == '') {
    return;
  }
  require_once drupal_get_path('module', 'sf_prematch') . '/sf_prematch.main.inc';
  $map = salesforce_api_fieldmap_load($fieldmap_name);
  switch ($action) {
    case 'export':
      $result = sf_prematch_export($object_type, $object, $map, $match_by);
      break;
    case 'import':
      $result = sf_prematch_import($object_type, $object, $map, $match_by);
      break;
    default:
      $result = NULL;
      break;
  }
  return $result;
}