You are here

function drush_salesforce_sf_read_object in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 salesforce.drush.inc \drush_salesforce_sf_read_object()
  2. 8.3 salesforce.drush.inc \drush_salesforce_sf_read_object()
  3. 7.3 salesforce.drush.inc \drush_salesforce_sf_read_object()

Read a Salesforce object available to the logged-in user.

Parameters

string $id: The Salesforce ID.

Throws

\Exception

File

./salesforce.drush.inc, line 313
Drush integration for Salesforce.

Code

function drush_salesforce_sf_read_object($id) {
  _drush_salesforce_deprecated();
  $salesforce = \Drupal::service('salesforce.client');
  try {
    $name = $salesforce
      ->getObjectTypeName(new SFID($id));
    if ($object = $salesforce
      ->objectRead($name, $id)) {
      drush_print(dt('!type with id !id:', [
        '!type' => $object
          ->type(),
        '!id' => $object
          ->id(),
      ]));
      drush_print(drush_format($object
        ->fields()));
    }
  } catch (SalesforceException $e) {
    drush_log($e
      ->getMessage(), 'error');
  }
}