You are here

function hook_fieldmap_objects in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7 hooks.php \hook_fieldmap_objects()
  2. 7.2 salesforce_api.api.php \hook_fieldmap_objects()

Expose fields to fieldmappings.

Salesforce_api does not expose any Drupal fields. It's up to modules (e.g. sf_user and sf_node) to make those fields available for mapping. Developers implementing this hook should pay close attention to the import/export functions for each field, which are responsible for delivering the actual data for mapped fields. If import or export indexes are unset, salesforce_api will use the property of the object with the same fieldname. For example, "nid" does not have an import/export function, because "nid" is a property of the $node object.

For CCK fields, something special happens. When building the list of objects salesforce will attempt to locate export/import functions based on the naming convention _sf_node_export_cck_FIELDTYPE and _sf_node_import_cck_FIELDTYPE. For example, see _sf_node_export_cck_date and _sf_node_import_cck_date in sf_contrib. The default CCK handler will expose all columns from all CCK field types for export and import to and from Salesforce.

If the value of a particular column is not useful on its own, or if it needs to be manipulated in a specific way before being sent to Salesforce, then an export (and/or import as appropriate) override should be declared according to the naming convention (_sf_node_export_cck_FIELDTYPE). Any such function will automatically be used to export/import ALL columns for the CCK field type. Simple CCK fields with only a "value" column will be named after their field_name properties. CCK fields with columns other than "value" will be referred to according to the convention: FIELDNAME:COLUMN

If you want to expose additional non-cck fields for mapping, you should implement this hook, hook_fieldmap_objects.

If you want to change the default definition of a field or fields,

Parameters

$object_type: Where does the data come from? Either "drupal" or "salesforce".

Return value

The function should return an associative array of objects and their fields that should be made available for mapping. Each field is an associative array with the following keys (optional unless noted):

See also

_sf_node_export_cck_FIELDTYPE

_sf_node_import_cck_FIELDTYPE

hook_fieldmap_objects_alter

3 functions implement hook_fieldmap_objects()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

salesforce_api_fieldmap_objects in salesforce_api/salesforce_api.module
Implementation of hook_fieldmap_objects().
sf_node_fieldmap_objects in sf_node/sf_node.module
Implementation of hook_fieldmap_objects_alter().
sf_user_fieldmap_objects in sf_user/sf_user.module
Implementation of hook_fieldmap_objects().
1 invocation of hook_fieldmap_objects()
salesforce_api_fieldmap_objects_load in salesforce_api/salesforce_api.module
Returns all or a subset of the objects defined via hook_sf_fieldmap().

File

./hooks.php, line 98
These are the hooks that are invoked by the Salesforce core.

Code

function hook_fieldmap_objects($object_type) {
  if ($type == 'drupal') {
    return array(
      'node_page' => array(
        'label' => t('Page node'),
        'fields' => array(
          'nid' => array(
            'label' => t('Node ID'),
            'type' => SALESFORCE_FIELD_SOURCE_ONLY,
          ),
          'type' => array(
            'label' => t('Node type'),
          ),
          'status' => array(
            'label' => t('Is the node published?'),
          ),
          'field_sample_checkbox' => array(
            'label' => t('Widget Label'),
            'group' => t('CCK fields'),
            'export' => '_sf_node_export_cck_default',
            'import' => '_sf_node_import_cck_default',
            'multiple' => TRUE,
          ),
        ),
      ),
    );
  }
}