You are here

public function RestClient::getRecordTypeIdByDeveloperName in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getRecordTypeIdByDeveloperName()
  2. 5.0.x src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getRecordTypeIdByDeveloperName()

Given a DeveloperName and SObject Name, return SFID of the RecordType.

DeveloperName doesn't change between Salesforce environments, so it's safer to rely on compared to SFID.

Parameters

string $name: Object type name, E.g., Contact, Account.

string $devname: RecordType DeveloperName, e.g. Donation, Membership, etc.

bool $reset: If true, clear the local cache and fetch record types from API.

Return value

\Drupal\salesforce\SFID The Salesforce ID of the given Record Type, or null.

Throws

\Exception If record type is not found.

Overrides RestClientInterface::getRecordTypeIdByDeveloperName

File

src/Rest/RestClient.php, line 866

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

public function getRecordTypeIdByDeveloperName($name, $devname, $reset = FALSE) {
  $record_types = $this
    ->getRecordTypes($name, $reset);
  if (empty($record_types[$devname])) {
    throw new \Exception("No record type {$devname} for {$name}");
  }
  return $record_types[$devname]
    ->id();
}