Dynamic Field Mapping in a Template

When you build Blends (integrations) in Blendr.io, you apply field mappings all the time. Here's a typical example where you map outputs from one block to inputs of another block: alt text

These are static field mappings because they cannot be changed by an end-user that would activate this integration from a template.

Therefore it is possible to add a dynamic Field Mapping in the Setup Wizard of an integration template. This means that the user will be able to configure his own Field Mapping, and this Field Mapping will be used in the actual data sync in the Blend.

Click here for more information on How to create integration Templates ow to create Templates and how to create a Setup Wizard for a template.

Dynamic Field Mapping in a Setup Wizard of a Template

When you add a dynamic field mapping in a Setup flow of a Template, this is what it looks like for the user: alt text

The user can choose which fields from an input (in this example Eventbrite Attendees) are mapped to which fields of output (in this example Teamleader Contacts).

How to add a Dynamic Field Mapping

Add an input block to the Setup Flow, and add input of type Field Mapping: alt text

Add a list of possible field names (keys) for the left-hand side and right-hand side: alt text

The list of available keys can be a fixed list, which can be comma-separated or it can be an actual list/array.

The list of available keys can also be a dynamic list, such as in the above example for the keys on the right-hand side. Note that we first retrieved the list of custom fields in the Setup Flow (Block Teamleader List custom fields), and then we use the response in the Input block.

Make sure that the dynamic list only contains strings and not objects.

Allowed format for list:

[ firstname, lastname, company ]

Not allowed format for list:

[ {fieldname:firstname}, {fieldname:lastname}, {fieldname:company} ]

Make sure to persist all inputs in the Setup Flow: alt text

You can optionally define a default mapping, the default mapping should have the following format:

[ {from:{key:company}, to:{key:company_name}}, {from:{key:website}, to:{key:web}} ]

How to apply the Dynamic Field Mapping in a Blend

In the normal Run flow of the Blend (under the Start Block), use a Block called Transform object, which will apply the field mapping of the Setup Flow:

alt text

Warning:

Note

This block will be renamed to Apply field mapping to object in the future.

This block takes as input one Object (in this example an Eventbrite Attendee) and it will have a new object as output. The new object will have the keys as defined in the Field Mapping on the right-hand side.

In the above example, the Attendee object has nested properties and the block Transform object cannot handle those. Therefore we created a Variable of type Object and we used this to create a new Attendee object without nested properties: alt text

Example object with nested properties:

{ profile: { firstname: John, lastname: Doe } }

Example of new object without nested properties:

{ firstname: John, lastname: Doe }

The output from the block Transform Object is used to send data to the destination, in this case, the block Teamleader Create Contact:

Here's an example of mapping individual fields: alt text

Here's an example of mapping all fields at once, typically used to set e.g. custom fields: alt text

Note that we switched to Raw mode first, and then we referenced the full object from Transform Object, which is an object with key/values (not nested) and each key is a field name as configured in the Field Mapping on the right hand side.