public function RestClient::getRecordTypes in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getRecordTypes()
- 5.0.x src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getRecordTypes()
Retrieve all record types for this org.
If $name is provided, retrieve record types for the given object type only.
Parameters
string $name: Object type name, e.g. Contact, Account, etc.
Return value
array If $name is given, a record type array indexed by developer name. Otherwise, an array of record type arrays, indexed by object type name.
Overrides RestClientInterface::getRecordTypes
1 call to RestClient::getRecordTypes()
- RestClient::getRecordTypeIdByDeveloperName in src/
Rest/ RestClient.php - Given a DeveloperName and SObject Name, return SFID of the RecordType.
1 method overrides RestClient::getRecordTypes()
- TestRestClient::getRecordTypes in src/
Tests/ TestRestClient.php - Hard-code record types for testing.
File
- src/
Rest/ RestClient.php, line 839
Class
- RestClient
- Objects, properties, and methods to communicate with the Salesforce REST API.
Namespace
Drupal\salesforce\RestCode
public function getRecordTypes($name = NULL, $reset = FALSE) {
if (!$reset && ($cache = $this->cache
->get('salesforce:record_types'))) {
$record_types = $cache->data;
}
else {
$query = new SelectQuery('RecordType');
$query->fields = [
'Id',
'Name',
'DeveloperName',
'SobjectType',
];
$result = $this
->query($query);
$record_types = [];
foreach ($result
->records() as $rt) {
$record_types[$rt
->field('SobjectType')][$rt
->field('DeveloperName')] = $rt;
}
$this->cache
->set('salesforce:record_types', $record_types, $this
->getRequestTime() + self::CACHE_LIFETIME, [
'salesforce',
]);
}
if ($name != NULL) {
if (!isset($record_types[$name])) {
throw new \Exception("No record types for {$name}");
}
return $record_types[$name];
}
return $record_types;
}