function salesforce_api_get_updated in Salesforce Suite 6.2
Same name and namespace in other branches
- 7.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
$type: A string of the name of the Salesforce object to retrieve data for, 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 - Import Settings form.
File
- salesforce_api/
salesforce_api.module, line 1487 - Defines an API that enables modules to interact with the Salesforce server.
Code
function salesforce_api_get_updated($type, $start, $end) {
// If $type is an object, we only need the Salesforce type.
if (is_object($type) && $type->salesforce) {
$type = $type->salesforce;
}
if (!$type || !$start || !$end) {
return FALSE;
}
$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 (!empty($response->ids)) {
return $response;
}
else {
return FALSE;
}
}
}