You are here

public function Salesforce::getSobjectType in Salesforce Suite 7.3

Given a Salesforce ID, return the corresponding SObject name. (Based on keyPrefix from object definition,

Parameters

string $sfid: 15- or 18-character Salesforce ID

Return value

string sObject name, e.g. "Account", "Contact", "my__Custom_Object__c" or FALSE if no match could be found.

Throws

SalesforceException

See also

https://developer.salesforce.com/forums/?id=906F0000000901ZIAQ )

File

includes/salesforce.inc, line 73
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 getSobjectType($sfid) {
  $objects = $this
    ->objects(array(
    'keyPrefix' => substr($sfid, 0, 3),
  ));
  if (count($objects) == 1) {

    // keyPrefix is unique across objects. If there is exactly one return value from objects(), then we have a match.
    $object = reset($objects);
    return $object['name'];
  }

  // Otherwise, we did not find a match.
  return FALSE;
}