Field Mapping Instances

To use a Field Mapping, you need to create a Field Mapping Instance for a specific Connection.

Mapping Value is represented by two properties of the Field Mapping Instance:

  • importValue – mapping from external app schema to your app schema
  • exportValue – mapping from your app schema to external app schema

These are calculated values based on defaultImportValue/defaultExportValue that come from Field Mapping and config.importValue / config.exportValue that come from your user.

You can update the config part using the patch method:

UI

The simplest way to configure a Field Mapping is to use the configuration UI:

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .openConfiguration()

See more: Field Mapping UI

API

Here is how to use Field Mapping Instances via API or SDK.

Create

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .create()

Get

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPINGS_KEY}')
  .get()

Update

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .patch('{INPUT}')

Set up / Refresh

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .setup()

Reset

This method resets the field mapping instance to its default state, erasing all the customer configuration.

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .reset()

Archive

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPING_KEY}')
  .archive()

Multiple Field Mapping Instances per Connection

By default, every pair of Field Mapping and Connection will use the same Field Mapping Instance, which means that mapping values will be shared between them.

If you want to use multiple different mapping values for the same pair of Field Mapping + Connection, you should use instanceKey.

await integrationApp
  .connection('hubspot')
  .fieldMapping('{FIELD_MAPPINGS_KEY}', { instanceKey: '{INSTANCE_KEY}' })
  .get({ autoCreate: true })

When you apply instanceKey to a Field Mapping Instance, it will be automatically applied to the elements Field Mapping works with: Data Source, App Data Collection, etc.