You are here

function salesforce_api_get_updated in Salesforce Suite 7.2

Same name and namespace in other branches
  1. 6.2 salesforce_api/salesforce_api.module \salesforce_api_get_updated()

Wrapper for SOAP SforceBaseClient::getUpdated. Searches for records updated/created between start and end date.

Parameters

string $type: The name of the Salesforce object for which to retrieve data, or a Salesforce fieldmap object.

int $start: The timestamp for the beginning of the query.

int $end: The timestamp for the end of the query.

Return value

FALSE if failed, or an object containing an array of Ids and the latest date covered. $response->ids = array of SFIDS $response->latestDateCovered = timestamp of latest updated Salesforce object

2 string references to 'salesforce_api_get_updated'
sf_import_import_records in sf_import/sf_import.module
This function is called on cron run. It is responsible for calling functions to import records using the getUpdated() method or a custom SOQL query, depending on what the user selected in admin settings for sf_import.
sf_import_settings_form in sf_import/sf_import.admin.inc
Main import settings form for Salesforce Import module.

File

salesforce_api/salesforce_api.module, line 1782
Defines an API that enables modules to interact with the Salesforce server.

Code

function salesforce_api_get_updated($type, $start, $end) {
  if (!$type || !$start || !$end) {
    return FALSE;
  }

  // If $type is an object, we only need the Salesforce type.
  if (is_object($type) && $type->salesforce) {
    $type = $type->salesforce;
  }
  $sf = salesforce_api_connect();
  if ($sf) {
    try {
      $response = $sf->client
        ->getUpdated($type, (int) $start, (int) $end);
    } catch (Exception $e) {

      // Log the error message.
      salesforce_api_log(SALESFORCE_LOG_SOME, 'Could not get updated records from Salesforce: %message.', array(
        '%message' => $e->faultstring,
        '!debug' => check_plain($sf->client
          ->getLastRequest()),
      ), WATCHDOG_ERROR);

      // Indicate the failed action.
      return FALSE;
    }
    if (isset($response->ids)) {
      return $response;
    }
    else {
      return FALSE;
    }
  }
}