You are here

function salesforce_api_fieldmap_options in Salesforce Suite 7

Same name and namespace in other branches
  1. 5.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()
  2. 6.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()
  3. 7.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_options()

Returns an array of fieldmaps for use as options in the Forms API.


$entity: Filters the fieldmaps by entity.

$bundle: Filters the fieldmaps by bundle

$salesforce: Filters the fieldmaps by Salesforce object.

$automatic: Optional: Filter the fieldmaps to only pull those marked automatic.

Return value

A FAPI options array of all the matching fieldmaps.

1 call to salesforce_api_fieldmap_options()
sf_entity_salesforce_form in sf_entity/sf_entity.module


salesforce_api/salesforce_api.module, line 504
Defines an API that enables modules to interact with the Salesforce server.


function salesforce_api_fieldmap_options($entity = NULL, $bundle = NULL, $salesforce = NULL) {
  $options = array();

  // This does not need to not be optimized for perfomance since it's only an admin interface.
  $query = db_select('salesforce_field_map', 's')
  if (!empty($entity)) {
      ->condition('drupal_entity', $entity);
  if (!empty($bundle)) {
      ->condition('drupal_bundle', $bundle);
  if (!empty($salesforce)) {
      ->condition('salesforce', $salesforce, 'LIKE');
  $result = $query
  while ($map = $result
    ->fetch(PDO::FETCH_ASSOC)) {

    // Setup some replacement args for the label.
    $args = array(
      '@drupal' => salesforce_api_fieldmap_object_label('drupal', $map['drupal_bundle'], $map['drupal_entity']),
      '@salesforce' => salesforce_api_fieldmap_object_label('salesforce', 'salesforce', $map['salesforce']),
    $options[$map['fieldmap']] = t('Drupal @drupal to Salesforce @salesforce', $args);
  return $options;