Mapping
Data mapping comes as a crucial feature when you want your users to map their application platform’s fields to your fields in order to make sure the correct data is being synced from the platform and vice versa.
Such can be mappings can be either static or dynamic depending upon your use case. In either case, you’d have to create a Map-type dataslot setting in your application or workflow configuration settings in Cobalt. A Map-type dataslot is a type of User Setting that allows your users to define a mapping between an object in your application (an “Application Object”) and an object in their connected integration account (an “Integration Object”).
Static mapping
Static mapping essentially means that you have a set of pre-defined fields for which you want your users to map the respective application fields. User can create the required labels in the configuration pages specific to a workflow or the application itself in the cobalt dashboard.
.
On setting the static map-type dataslot, the config returns the application fields along with the created labels. These labels consist of the name provided by you and system generated
static value. This value
is mapped to the application platform fields.
Next time when you’d like to update the value of the mapped field with some data, send the data against
the system generated value
.
Dynamic mapping
Scenarios where the fields cannot be pre-defined for mapping and changes dynamically cannot be mapped using static mapping. For this Cobalt provides a feature To
map your labels dynamically while creating your config. To do so, instead of creating the labels in the configuration pages specific to a workflow or the application,
simply toggle the Dynamic
option of the data slot and provide the Labels Object Name
.
.
Now while creating the config using .config()
method, pass on the required dynamic labels under the created Labels Object Name
. Check out this documentation for more details.
Note here that unlike static mapping, the label value here is not system generated but defined by the user.
Getting map-type config from frontend SDK
Use the config() function to get the config of a particular app.
cobalt.config('mailerlite','configid');
Let’s look at a sample response of map-type dataslot.
As you can see, the previously empty ‘labels’ array now has the options configured above on the platform - ‘Name’ and ‘Email’.
Updating value of map-type config
Use the updateConfig() function to save the selected value. In this case an object with respective labels and their values will be needed to pass.
It will return the same response as config() functions with updates in the changed value. You will notice that the value is now added in the object.