function hook_salesforce_push_fail in Salesforce Suite 7.3
Same name and namespace in other branches
- 8.4 salesforce.api.php \hook_salesforce_push_fail()
- 8.3 salesforce.api.php \hook_salesforce_push_fail()
- 5.0.x salesforce.api.php \hook_salesforce_push_fail()
A salesforce push has failed: Implementations may wish to react, for example, by logging the failure or alerting an administrator.
Parameters
string $op: The salesforce operation: Create, Update, Upsert, or Delete
object $result: The salesforce response
array $synced_entity: Entity data for this push. This array has 4 keys 'entity_wrapper': entity_metadata_wrapper() for the Drupal entity 'mapping_object': salesforce mapping object record, if it exists. Otherwise null 'queue_item': If this is a SOAP push, Drupal queue item corresponding to this push attempt. Otherwise FALSE. 'mapping': SalesforceMapping being used for this push
Related topics
2 invocations of hook_salesforce_push_fail()
- salesforce_push_process_soap_results in modules/
salesforce_push/ salesforce_push.module - Process SOAP API batch results.
- salesforce_push_sync_rest in modules/
salesforce_push/ salesforce_push.module - Sync Drupal entities and Salesforce objects using the REST API.
File
- ./
salesforce.api.php, line 281 - These are the hooks that are invoked by the Salesforce core.
Code
function hook_salesforce_push_fail($op, $result, $synced_entity) {
$error_messages = array();
foreach ($result->errors as $error) {
watchdog('salesforce_push', '%op error for Salesforce object %id. @code: @message', array(
'%id' => $result->id,
'@code' => $error->statusCode,
'@message' => $error->message,
'%op' => $op,
), WATCHDOG_ERROR);
$error_messages[] = $error->message;
}
if (!empty($synced_entity['mapping_object'])) {
$mapping_object = $synced_entity['mapping_object'];
$mapping_object->last_sync = REQUEST_TIME;
$mapping_object->last_sync_action = 'push';
$mapping_object->last_sync_status = SALESFORCE_MAPPING_STATUS_ERROR;
$mapping_object->last_sync_message = truncate_utf8(t('Push error via %function. Message: @message', array(
'%function' => __FUNCTION__,
'@message' => implode(' | ', $error_messages),
)), 255, FALSE, TRUE);
$mapping_object
->save();
}
}