function hook_salesforce_pull_mapping_object_alter in Salesforce Suite 7.3
Same name and namespace in other branches
- 8.4 salesforce.api.php \hook_salesforce_pull_mapping_object_alter()
- 8.3 salesforce.api.php \hook_salesforce_pull_mapping_object_alter()
- 5.0.x salesforce.api.php \hook_salesforce_pull_mapping_object_alter()
Define or alter the mapping object during a pull.
Parameters
mixed $mapping_object: The mapping object that was detected based on existing mappings or FALSE if no exisitng mapping object exists.
array $sf_object: The salesforce object data that will be used in this pull.
SalesforceMapping $mapping: The salesforce mapping that will be used during the pull.
Related topics
1 invocation of hook_salesforce_pull_mapping_object_alter()
- salesforce_pull_process_updated_records in modules/
salesforce_pull/ salesforce_pull.module - Process records in the queue.
File
- ./
salesforce.api.php, line 44 - These are the hooks that are invoked by the Salesforce core.
Code
function hook_salesforce_pull_mapping_object_alter(&$mapping_object, $sf_object, $mapping) {
// Do some prematching for incoming user pulls if we don't already have a
// match.
if (!$mapping_object && $mapping->drupal_entity_type == 'user') {
// Run some complex custom prematching logic that searches for an existing
// Drupal user that is a match to the incoming Salesforce data.
$matched_user = mymodule_custom_sf_pull_prematch($sf_object, $mapping);
if ($matched_user) {
// If we have a match create mapping object on-the-fly and then reload it
// This means that the rest of the pull logic will target this matched
// user instead of creating a new one.
entity_create('salesforce_mapping_object', array(
'salesforce_id' => $sf_object['Id'],
'entity_type' => $mapping->drupal_entity_type,
'entity_id' => $matched_user->uid,
'last_sync_message' => t('User prematch on pull'),
'last_sync_status' => SALESFORCE_MAPPING_STATUS_SUCCESS,
))
->save();
$mapping_object = salesforce_mapping_object_load_by_sfid($sf_object['Id'], TRUE);
}
}
}