Mapping Framework
When to Use
Use
salesforce_mappingfor any entity sync between Drupal and Salesforce. It provides theSalesforceMappingconfig entity (defines the relationship) andMappedObjectcontent entity (tracks individual record links).
Decision
| Field Mapping Plugin | Use When |
|---|---|
Properties |
Standard Drupal field → Salesforce field mapping |
PropertiesExtended |
Need transformations on standard properties |
RelatedProperties |
Map a field from a related entity |
RelatedIDs |
Map entity reference IDs |
RelatedTermString |
Map taxonomy term names |
Token |
Value derived from token replacement |
Constant |
Static hardcoded value |
DrupalConstant |
PHP constant value |
RecordType |
Salesforce RecordType mapping |
Pattern
Two entity types:
SalesforceMapping (config entity)
- Entity type + bundle
- Salesforce object name
- Field mappings
- Sync triggers (push_create, pull_update, etc.)
└── Stored: config/sync/salesforce_mapping.salesforce_mapping.[id].yml
MappedObject (content entity, revisionable)
- Links one Drupal entity ↔ one Salesforce record
- Stores SFID, last sync timestamp
- Maintains sync history via revisions
Key services:
plugin.manager.salesforce_mapping_field — field mapping plugins
salesforce_mapping.mappable_entity_types — entity type discovery
entity_type.manager->getStorage('salesforce_mapped_object')
Common Mistakes
- Wrong: Creating a custom field mapping by copying the entity and bypassing the plugin system → Right: Extend
PropertiesBasefor custom field mapping logic - Wrong: Editing
MappedObjectrecords directly to change SFID → Right: Use thePUSH_MAPPING_OBJECTevent to modify the mapped object during sync
See Also
- Mapping UI & Sync Triggers
- Custom Field Mapping Plugin
- Mapped Objects API
- Reference:
/web/modules/contrib/salesforce/modules/salesforce_mapping/src/Entity/SalesforceMapping.php - Reference:
/web/modules/contrib/salesforce/modules/salesforce_mapping/src/Entity/MappedObject.php - Reference example:
/web/modules/contrib/salesforce/modules/salesforce_example/src/Plugin/SalesforceMappingField/Hardcoded.php