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

Step 1: Adding to the User Portal

Map dataslot settings can be added by visiting the “configure” option inside an application on your dashboard.

An example of a map-type dataslot. For eg. List of fields in Mailerlite can be mapped with user inputs.

Step 2: 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’.

{
    "application_data_slots": [
        {
            "required": true,
            "id": "645df2f8e77af6ed8d02f32f",
            "name": "Map Mailerlite Fields",
            "has_dynamic_map_fields": false,
            "field_type": "map",
            "options": [
                {
                    "name": "City",
                    "value": "city"
                },
                {
                    "name": "Company",
                    "value": "company"
                },
                {
                    "name": "Country",
                    "value": "country"
                },
                {
                    "name": "Last name",
                    "value": "last_name"
                },
                {
                    "name": "Name",
                    "value": "name"
                },
                {
                    "name": "Phone",
                    "value": "phone"
                },
                {
                    "name": "Secondary_Email",
                    "value": "secondary_email"
                }
            ],
            "dynamic_slot_identifier": "dynamic:mailerlite:1",
            "labels": [
                {
                    "name": "Name",
                    "value": "645df30fe77af6ed8d02f338"
                },
                {
                    "name": "Email",
                    "value": "645df30fe77af6ed8d02f339"
                }
            ]
        }
    ],
    "workflows": [],
    "config_id": "1234"
}

Step 3: 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.

cobalt.updateConfig('pipedrive','1234',{
    "config_id": "1234",
    "application_data_slots": {
        "645df2f8e77af6ed8d02f32f": {
            "645df30fe77af6ed8d02f339": "secondary_email",
            "645df30fe77af6ed8d02f338": "name"
            }
        /*[response.application_data_slots[0].id] : {
            [response.application_data_slots[0].labels[0].value]: response.application_data_slots[0].options[4].value
            [response.application_data_slots[0].labels[1].value]: response.application_data_slots[0].options[6].value
          } 
        */
    },
    "workflows": []
});

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.

{
    "application_data_slots": [
        {
            "required": true,
            "id": "645df2f8e77af6ed8d02f32f",
            "name": "Map Mailerlite Fields",
            "has_dynamic_map_fields": false,
            "field_type": "map",
            "options": [
                {
                    "name": "City",
                    "value": "city"
                },
                {
                    "name": "Company",
                    "value": "company"
                },
                {
                    "name": "Country",
                    "value": "country"
                },
                {
                    "name": "Last name",
                    "value": "last_name"
                },
                {
                    "name": "Name",
                    "value": "name"
                },
                {
                    "name": "Phone",
                    "value": "phone"
                },
                {
                    "name": "Secondary_Email",
                    "value": "secondary_email"
                }
            ],
            "dynamic_slot_identifier": "dynamic:mailerlite:1",
            "labels": [
                {
                    "name": "Name",
                    "value": "645df30fe77af6ed8d02f338"
                },
                {
                    "name": "Email",
                    "value": "645df30fe77af6ed8d02f339"
                }
            ],
            "value": {
                "645df30fe77af6ed8d02f339": "secondary_email",
                "645df30fe77af6ed8d02f338": "name"
            }
        }
    ],
    "workflows": [],
    "config_id": "1234"
}

Summary of setting a map-type config dataslot using config() and updateConfig() functions