You are here

function salesforce_account_select in Salesforce Suite 5

Same name and namespace in other branches
  1. 5.2 includes/salesforce_api.inc \salesforce_account_select()

select from the salesforce contact table

2 calls to salesforce_account_select()
salesforce_contract_select in includes/salesforce_api.inc
retreive contract information from an account
_salesforce_admin_list in ./salesforce.module
helper functions

File

includes/salesforce_api.inc, line 331
integration of Drupal and Salesforce.com. Original author: Steve Mckenzie Current maintainer: Victor Kane

Code

function salesforce_account_select($account = NULL, $params = array(), $cache = true) {
  $salesforce = salesforce();
  $account = _salesforce_select_account($account);

  // make sure we're dealing with a contact
  if (!$account->salesforce['contact_id']) {
    return array(
      'error' => 'NO_CONTACT_ID',
    );
  }
  $defaults = array(
    'accountId',
  );
  $params = array_merge($defaults, $params);

  // query salesforce for the contact's account_id
  $contact = $salesforce
    ->query("SELECT " . implode(',', $params) . " FROM contact WHERE id = '" . $account->salesforce['contact_id'] . "'");
  $id = $contact['records']->values['AccountId'];
  if ($id) {
    if ($cache) {
      _salesforce_insert('account_id', $id, $account);
    }
    return $contact['records']->values;
  }
}