Integration Mapping
The Integration Mapping module (prefix IM_) provides a shared mapping
layer for translating between external system payloads and Salesforce
SObject records. It defines the global contracts, service, and extension
point used to configure and resolve field-level mappings for
integrations.
The module exposes the following globally:
-
Mapping Service Interface (
mvn.IM_IMappingService) - the service interface for resolving connections and field mappings and for translating values in each direction. -
Value Transformer Interface (
mvn.IM_IValueTransformer) - the extension point for adding custom value transformation logic. -
Connection Config (
mvn.IM_ConnectionConfig), Field Mapping (mvn.IM_FieldMapping), and Value Mapping (mvn.IM_ValueMapping) - the data transfer objects returned by the service.
Mapping Service Interface
The Mapping Service (mvn.IM_IMappingService) global Apex interface exposes
the methods for resolving connection configurations, retrieving field
mappings, and translating values between a remote system and Salesforce.
Obtain an instance via the static factory on mvn.IM_MappingService:
mvn.IM_IMappingService svc = mvn.IM_MappingService.getInstance();
The interface divides into two groups: methods that can be called on a fresh instance, and methods that require setConnection(developerName, direction) to be called first.
Method(s)
getConnection(integrationType, instanceIdentifier)
mvn.IM_ConnectionConfig getConnection(String integrationType, String instanceIdentifier)
This method looks up a connection configuration by integration type and
optional instance identifier. It can be called on a fresh instance. When
instanceIdentifier is non-blank, it first attempts to find a connection
matching both the integration type and instance identifier. If no
instance-specific record is found, or instanceIdentifier is blank or
null, it falls back to the default connection for the integration type
(the active record whose connection type is Default).
| Returns | The matching Connection Config, or null if no matching connection exists. |
|---|
| Parameter | Type | Description |
|---|---|---|
| integrationType | String | The logical integration type to look up (for example, Salesforce or SFTP). |
| instanceIdentifier | String | The instance identifier used to distinguish multiple instances of the same integration type. Pass null or a blank value to retrieve the default connection. |
getConnections(integrationType)
List<mvn.IM_ConnectionConfig> getConnections(String integrationType)
This method returns all active, non-shared connection configurations for
the given integration type. It is useful when you need to enumerate all
instances of a particular integration, such as to fan out a sync job.
Inactive connections and connections whose connection type is
SharedMapping are excluded.
| Returns | A list of matching Connection Config records, or an empty list if none are found. |
|---|
| Parameter | Type | Description |
|---|---|---|
| integrationType | String | The logical integration type whose connections are returned. |
setConnection(developerName, direction)
void setConnection(String developerName, mvn.IM_MappingService.Direction direction)
This method initializes the service instance for a specific connection and data-flow direction. It must be called before getConnection() or getFieldMappings(objectApiName, recordType).
It loads the active connection record with the given developer name and sets the active direction, which governs which field mappings are returned by getFieldMappings(objectApiName, recordType). All field mappings for the specified connection and for any shared connections of the same integration type are loaded eagerly, and specific-connection mappings take priority over shared mappings. Value mappings for all loaded field mappings are fetched in a single query and attached to their field mappings.
| Returns | void |
|---|
| Parameter | Type | Description |
|---|---|---|
| developerName | String | The developer name of the active connection to initialize. If no matching active connection exists, an IllegalArgumentException is thrown. |
| direction | mvn.IM_MappingService.Direction | The data-flow direction for this session. See the Direction enum. |
Direction enum
The Direction enum is defined on the mvn.IM_MappingService class.
| Value | Description |
|---|---|
| INBOUND | Remote system to Salesforce. Only field mappings with an inbound (or bidirectional) direction are returned. |
| OUTBOUND | Salesforce to remote system. Only field mappings with an outbound (or bidirectional) direction are returned. |
getConnection()
mvn.IM_ConnectionConfig getConnection()
This method returns the connection configuration that was resolved during setConnection(developerName, direction).
| Returns | The Connection Config resolved during setConnection(), or null if setConnection() has not been called on this instance. |
|---|
getFieldMappings(objectApiName, recordType)
List<mvn.IM_FieldMapping> getFieldMappings(String objectApiName, String recordType)
This method returns the filtered, deduplicated list of field mappings for
the given object and the direction set by
setConnection(developerName,
direction). The meaning of
objectApiName depends on the direction: for INBOUND it is the remote
object name, and for OUTBOUND it is the Salesforce SObject API name.
A mapping whose record type exactly matches the requested record type
takes precedence over a mapping with the record type All for the same
logical field. If no exact match exists, the All fallback is returned. A
blank or null recordType is treated as All. The returned list is
unordered.
| Returns | A list of Field Mapping records for the object and active direction. |
|---|
| Parameter | Type | Description |
|---|---|---|
| objectApiName | String | For INBOUND, the remote object name (for example, Contact); for OUTBOUND, the Salesforce SObject API name (for example, Account). An IllegalArgumentException is thrown if setConnection() has not been called or if this value is null. |
| recordType | String | The record type developer name to filter by. Pass null or a blank value to use the All mappings. |
toSalesforce(fieldMapping, remoteValue)
Object toSalesforce(mvn.IM_FieldMapping fieldMapping, Object remoteValue)
This method translates a single remote value to its Salesforce equivalent for the given field mapping. The remote value is matched case-insensitively against the field mapping's value mappings; a single match returns the mapped Salesforce value, multiple matches return the mapped values joined with the standard multi-value separator, and no match passes the original value through. The resolved value is then coerced to the appropriate Apex type based on the mapping's remote data type. If the field mapping specifies a transform class, its transformInbound(remoteValue, mapping) method is called as the final step.
| Returns | The translated Salesforce value, or the original value passed through if no value mapping matches. |
|---|
| Parameter | Type | Description |
|---|---|---|
| fieldMapping | mvn.IM_FieldMapping | The Field Mapping that defines how the value is translated. |
| remoteValue | Object | The remote value to translate. When the mapping's remote path is blank, this is treated as null. |
toRemote(fieldMapping, sfValue)
Object toRemote(mvn.IM_FieldMapping fieldMapping, Object sfValue)
This method translates a single Salesforce value to its remote equivalent for the given field mapping. The Salesforce value is matched case-insensitively against the field mapping's value mappings; a single match returns the mapped remote value, multiple matches return a list of matching remote values, and no match passes the original value through unchanged. Type coercion and any configured transform class (transformOutbound(sfValue, mapping)) are applied as with toSalesforce(fieldMapping, remoteValue).
| Returns | The translated remote value, or the original value passed through if no value mapping matches. |
|---|
| Parameter | Type | Description |
|---|---|---|
| fieldMapping | mvn.IM_FieldMapping | The Field Mapping that defines how the value is translated. |
| sfValue | Object | The Salesforce value to translate. When the mapping's Salesforce field API name is blank, this is treated as null. |
Value Transformer Interface
The Value Transformer (mvn.IM_IValueTransformer) global Apex interface is
the extension point for adding custom transformation logic beyond discrete
value mapping. Implement this interface and set the field mapping's
transform class to the fully qualified Apex class name to have it invoked
as the final step of a translation.
global interface mvn.IM_IValueTransformer
The transformer receives the already coerced value (after type coercion
and value mapping have been applied). If the transformer class cannot be
found, cannot be cast to mvn.IM_IValueTransformer, or throws during
execution, the mapping call fails rather than silently passing the value
through.
Method(s)
transformInbound(remoteValue, mapping)
Object transformInbound(Object remoteValue, mvn.IM_FieldMapping mapping)
This method applies custom transformation logic when translating a remote value to Salesforce. It is called by toSalesforce(fieldMapping, remoteValue) as the final step.
| Returns | The transformed value. Return null only if you intend to null out the field value. |
|---|
| Parameter | Type | Description |
|---|---|---|
| remoteValue | Object | The already coerced remote value to transform. |
| mapping | mvn.IM_FieldMapping | The full Field Mapping, providing access to all metadata fields for context-dependent logic. |
transformOutbound(sfValue, mapping)
Object transformOutbound(Object sfValue, mvn.IM_FieldMapping mapping)
This method applies custom transformation logic when translating a Salesforce value to the remote system. It is called by toRemote(fieldMapping, sfValue) as the final step.
| Returns | The transformed value. Return null only if you intend to null out the field value. |
|---|
| Parameter | Type | Description |
|---|---|---|
| sfValue | Object | The already coerced Salesforce value to transform. |
| mapping | mvn.IM_FieldMapping | The full Field Mapping, providing access to all metadata fields for context-dependent logic. |
Connection Config
The Connection Config (mvn.IM_ConnectionConfig) global Apex class represents
a single integration connection configuration record.
global class mvn.IM_ConnectionConfig
| Property | Type | Description |
|---|---|---|
| developerName | String | The unique developer name for this connection. |
| integrationType | String | The logical integration type (for example, Salesforce or SFTP). |
| instanceKey | String | Distinguishes multiple instances of the same integration type; null for the default connection. |
| active | Boolean | Whether this connection is active. |
| connectionType | String | The connection classification, such as Default or SharedMapping. |
| namedCredential | String | The named credential used for callouts. |
| apiVersion | Decimal | The API version for the remote system. |
| callTimeout | Integer | The callout timeout in milliseconds; null if not set. |
| batchSize | Integer | The preferred batch size for bulk operations; null if not set. |
| whereCondition | String | An optional filter condition string for data sync queries. |
Field Mapping
The Field Mapping (mvn.IM_FieldMapping) global Apex class represents a
single field-level mapping between a Salesforce field and a remote system
field.
global class mvn.IM_FieldMapping
| Property | Type | Description |
|---|---|---|
| connectionDeveloperName | String | The connection this mapping belongs to. |
| sfObjectApiName | String | The API name of the Salesforce SObject (for example, Account). |
| sfFieldApiName | String | The API name of the Salesforce field; null for virtual or derived mappings. |
| sfRecordType | String | The record type developer name this mapping applies to; defaults to All if not specified. |
| remoteObject | String | The logical name of the remote object or entity. |
| remotePath | String | The JSON path or field name in the remote payload; null for virtual or derived mappings. |
| remoteDataType | String | The data type hint used to coerce the remote value. |
| inbound | Boolean | true when this mapping applies to inbound (remote to Salesforce) translation. |
| outbound | Boolean | true when this mapping applies to outbound (Salesforce to remote) translation. |
| transformClass | String | The fully qualified Apex class name implementing Value Transformer Interface; null if no custom transform. |
| valueMappings | List<mvn.IM_ValueMapping> | The discrete value translation table; an empty list if none are configured. Never null. |
Value Mapping
The Value Mapping (mvn.IM_ValueMapping) global Apex class represents a
single row in a discrete value translation table as a bidirectional value
pair.
global class mvn.IM_ValueMapping
| Property | Type | Description |
|---|---|---|
| sfValue | String | The Salesforce picklist value or equivalent. |
| remoteValue | String | The corresponding value in the remote system. |
Blank entries (empty string or null) are valid and meaningful: they
represent a case where no value on one side maps to a specific value on
the other side. The lookup logic in toSalesforce(fieldMapping,
remoteValue) and
toRemote(fieldMapping, sfValue) matches
blank-to-blank.
