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.
Step 2
Begin the parameter setup for your pipe, shown in the image below.
Find these three values for the parameter values of your pipe.
1. Parent Record ID
2. Child Table ID
3. Connection Field Slug
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.
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, ", ");
Step 4
Set up a table rule in your parent table with the setting shown in the image below.
Step 5
On the page builder side. Add a form rule to update the connected parent table in the form of the child table.
We'd love to hear your feedback.