You are here

function hook_salesforce_pull_entity_insert in Salesforce Suite 7.3

Same name and namespace in other branches
  1. 8.4 salesforce.api.php \hook_salesforce_pull_entity_insert()
  2. 8.3 salesforce.api.php \hook_salesforce_pull_entity_insert()
  3. 5.0.x salesforce.api.php \hook_salesforce_pull_entity_insert()

Act on an entity after it is inserted by a salesforce pull operation. Implementations may throw SalesforcePullException to prevent updating of the Salesforce Mapping Object, but the entity will already have been saved.

Parameters

$entity: The Drupal entity object.

array $sf_object: The SObject from the pull query (as an array).

SalesforceMapping $sf_mapping: The Salesforce Mapping being used to pull this record

Throws

SalesforcePullException

Related topics

1 invocation of hook_salesforce_pull_entity_insert()
salesforce_pull_process_updated_records in modules/salesforce_pull/salesforce_pull.module
Process records in the queue.

File

./salesforce.api.php, line 343
These are the hooks that are invoked by the Salesforce core.

Code

function hook_salesforce_pull_entity_insert($entity, $sf_object, $sf_mapping) {

  // Insert the new entity into a fictional table of all Salesforce-sourced
  // entities.
  $type = $sf_mapping->drupal_entity_type;
  $info = entity_get_info($type);
  list($id) = entity_extract_ids($type, $entity);
  db_insert('example_sf_entity')
    ->fields(array(
    'type' => $type,
    'id' => $id,
    'sf_name' => $sf_object['Name'],
    'created' => REQUEST_TIME,
    'updated' => REQUEST_TIME,
  ))
    ->execute();
}