public function Salesforce::objectDescribe in Salesforce Suite 7.3
Retreieve all the metadata for an object.
Parameters
string $name: Object type name, E.g., Contact, Account, etc.
bool $reset: Whether to reset the cache and retrieve a fresh version from Salesforce.
Return value
array All the metadata for an object, including information about each field, URLs, and child relationships.
File
- includes/
salesforce.inc, line 568 - Objects, properties, and methods to communicate with the Salesforce REST API
Class
- Salesforce
- Ability to authorize and communicate with the Salesforce REST API.
Code
public function objectDescribe($name, $reset = FALSE) {
if (empty($name)) {
return array();
}
$cache = cache_get($name, 'cache_salesforce_object');
// Force the recreation of the cache when it is older than 5 minutes.
if ($cache && REQUEST_TIME < $cache->created + 300 && !$reset) {
return $cache->data;
}
else {
$object = $this
->apiCall("sobjects/{$name}/describe");
// Sort field properties, because salesforce API always provides them in a
// random order. We sort them so that stored and exported data are
// standardized and predictable.
$fields = array();
foreach ($object['fields'] as $field) {
ksort($field);
if (!empty($field['picklistValues'])) {
foreach ($field['picklistValues'] as &$picklist_value) {
ksort($picklist_value);
}
}
$fields[$field['name']] = $field;
}
ksort($fields);
$object['fields'] = $fields;
// Allow the cache to clear at any time by not setting an expire time.
cache_set($name, $object, 'cache_salesforce_object', CACHE_TEMPORARY);
return $object;
}
}