Concatenate Multi-Select Connections

This is a solution if you have many tables that are children of the other and want to rollup multi-select connections.

  • Not yet re-checked
  • Classic builder

Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

Screenshot for “Concatenate Multi-Select Connections”

This is a solution if you have many tables that are children of the other and want to rollup multi-select connections.

Step 1

Download the Custom JavaScript pipe from our pipe library.

Screenshot for “Concatenate Multi-Select Connections”

Step 2

Begin the parameter setup for your pipe, shown in the image below.

Screenshot for “Concatenate Multi-Select Connections”

Find these three values for the parameter values of your pipe.

1. Parent Record ID

2. Child Table ID

Screenshot for “Concatenate Multi-Select Connections”

3. Connection Field Slug

Screenshot for “Concatenate Multi-Select Connections”

Step 3

Add the following code to the request tab of the pipe and update the API portion with your API values, as seen in the image below. Additionally, update the portion "var One_To_Many_Field = ' ' this will be the same field slug we found in step 2.

Text
var Tadabase_Api_Id = 'APP_ID';
var Tadabase_Api_Key = 'API_KEY';
var Tadabase_Api_Secret = 'API_SECRET';
var Parent_Record_Id = '{parentRecordId}';
var Child_Table_Id = '{childTableId}';
var Connection_From_Child_To_Parent = '{fieldSlug}';
var One_To_Many_Field = 'field_ID_val';

Array.prototype.contains = function(v) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] === v) return true;
    }
    return false;
};
Array.prototype.unique = function() {
    var arr = [];
    for (var i = 0; i < this.length; i++) {
        if (!arr.contains(this[i])) {
            arr.push(this[i]);
        }
    }
    return arr;
}
var Api_Url = 'https://api.tadabase.io/api/v1/data-tables';
var Request_Var = {
    'method': 'GET',
    'headers': {
        "X-Tadabase-App-id": Tadabase_Api_Id,
        "X-Tadabase-App-Key": Tadabase_Api_Key,
        "X-Tadabase-App-Secret": Tadabase_Api_Secret
    }
};

function getChildRecords() {
    var response = UrlFetchApp.fetch(Api_Url + "/" + Child_Table_Id + "/records/?filters[items][0][field_id]=" + Connection_From_Child_To_Parent + "&filters[items][0][operator]=is&filters[items][0][val]=" + Parent_Record_Id, Request_Var);
    return JSON.parse(response);
}
var childItems = getChildRecords();
var listOfJoinValues = [];
for (var i = 0; i < childItems.items.length; i++) {
    var element = childItems.items[i];
    for (var j in element[One_To_Many_Field]) {
        var item = element[One_To_Many_Field][j];
        listOfJoinValues.push(item.val)
    }
}
var uniques = listOfJoinValues.unique();
uniques.toString().replace(/,,/g, ",").replace(/,/g, ", ");
Screenshot for “Concatenate Multi-Select Connections”

Step 4

Set up a table rule in your parent table with the setting shown in the image below.

Screenshot for “Concatenate Multi-Select Connections”

Step 5

On the page builder side. Add a form rule to update the connected parent table in the form of the child table.

Screenshot for “Concatenate Multi-Select Connections”

Original Community Post:

Concatenating (merging) the multi-select results of a child table into the parent - Community Discussions / How to Do I - Tadabase Community

Was this page helpful?

Something wrong or missing on this page? Tell us.