Skip to main content

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​

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).

ReturnsThe matching Connection Config, or null if no matching connection exists.
ParameterTypeDescription
integrationTypeStringThe logical integration type to look up (for example, Salesforce or SFTP).
instanceIdentifierStringThe 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.

ReturnsA list of matching Connection Config records, or an empty list if none are found.
ParameterTypeDescription
integrationTypeStringThe 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.

Returnsvoid
ParameterTypeDescription
developerNameStringThe developer name of the active connection to initialize. If no matching active connection exists, an IllegalArgumentException is thrown.
directionmvn.IM_MappingService.DirectionThe data-flow direction for this session. See the Direction enum.
Direction enum​

The Direction enum is defined on the mvn.IM_MappingService class.

ValueDescription
INBOUNDRemote system to Salesforce. Only field mappings with an inbound (or bidirectional) direction are returned.
OUTBOUNDSalesforce 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).

ReturnsThe 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.

ReturnsA list of Field Mapping records for the object and active direction.
ParameterTypeDescription
objectApiNameStringFor 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.
recordTypeStringThe 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.

ReturnsThe translated Salesforce value, or the original value passed through if no value mapping matches.
ParameterTypeDescription
fieldMappingmvn.IM_FieldMappingThe Field Mapping that defines how the value is translated.
remoteValueObjectThe 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).

ReturnsThe translated remote value, or the original value passed through if no value mapping matches.
ParameterTypeDescription
fieldMappingmvn.IM_FieldMappingThe Field Mapping that defines how the value is translated.
sfValueObjectThe 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.

ReturnsThe transformed value. Return null only if you intend to null out the field value.
ParameterTypeDescription
remoteValueObjectThe already coerced remote value to transform.
mappingmvn.IM_FieldMappingThe 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.

ReturnsThe transformed value. Return null only if you intend to null out the field value.
ParameterTypeDescription
sfValueObjectThe already coerced Salesforce value to transform.
mappingmvn.IM_FieldMappingThe 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

PropertyTypeDescription
developerNameStringThe unique developer name for this connection.
integrationTypeStringThe logical integration type (for example, Salesforce or SFTP).
instanceKeyStringDistinguishes multiple instances of the same integration type; null for the default connection.
activeBooleanWhether this connection is active.
connectionTypeStringThe connection classification, such as Default or SharedMapping.
namedCredentialStringThe named credential used for callouts.
apiVersionDecimalThe API version for the remote system.
callTimeoutIntegerThe callout timeout in milliseconds; null if not set.
batchSizeIntegerThe preferred batch size for bulk operations; null if not set.
whereConditionStringAn 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

PropertyTypeDescription
connectionDeveloperNameStringThe connection this mapping belongs to.
sfObjectApiNameStringThe API name of the Salesforce SObject (for example, Account).
sfFieldApiNameStringThe API name of the Salesforce field; null for virtual or derived mappings.
sfRecordTypeStringThe record type developer name this mapping applies to; defaults to All if not specified.
remoteObjectStringThe logical name of the remote object or entity.
remotePathStringThe JSON path or field name in the remote payload; null for virtual or derived mappings.
remoteDataTypeStringThe data type hint used to coerce the remote value.
inboundBooleantrue when this mapping applies to inbound (remote to Salesforce) translation.
outboundBooleantrue when this mapping applies to outbound (Salesforce to remote) translation.
transformClassStringThe fully qualified Apex class name implementing Value Transformer Interface; null if no custom transform.
valueMappingsList<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

PropertyTypeDescription
sfValueStringThe Salesforce picklist value or equivalent.
remoteValueStringThe 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.