Create X Amount of Connected Records Based on a Number Field
The following demonstration will show you how to create X amount of connected Child records based on a Number field in the Parent table.
Step 1
Download the custom JavaScript pipe. Set up the parameters as seen below in a run serverside JavaScript call.
Step 2
Add the following code to the request tab. Update your API keys.
var appId = 'APP_ID';
var apiKey = 'API_KEY';
var apiSecret = 'API_SECRET';
var childTable = 'CHILD_TABLE_ID';
var childJoinFieldId = 'field_ID';
var parentRecordId = '{parentRecordId}';
if ('{flag}' === '{flagValue}') {
for (let i = 0; i < {
qty
}; i++) {
var settings = {
"method": "POST",
"headers": {
"X-Tadabase-App-id": appId,
"X-Tadabase-App-Key": apiKey,
"X-Tadabase-App-Secret": apiSecret,
}
};
var data = {
[childJoinFieldId]: parentRecordId
}
var request = settings;
request.method = 'POST';
request.payload = data;
UrlFetchApp.fetch("https://api.tadabase.io/api/v1/data-tables/" + childTable + "/records", request);
}
}
Step 3
Still editing the request-response, we will now update the child table ID and the field ID. The location of these values can be found here in the image below.
Step 4
Add the following table rule to your parent table.
Original Community post:
Please see the original community post for further customization options.
We'd love to hear your feedback.