Help

Create multiple records from parent table

Topic Labels: Automations
1183 2
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi all. I have several tables, Batches, Protocol, Points & Stability. In table Protocol I have a linked field to batch# in Batches, and 2 more fields, a single select; and another multiple linked field from 3rd table Points that makes an array of a variable number of Points (1 month, 3 months, etc.) for a record in Protocol.
My goal is to get any automation if possible, when a new record in Protocol is made (with multiple n points field), to create n new records in the Stability table according the number of points, where each new record pulls the different points of the array and the single select.
This is needed because in Stability table each record uses a initial date field and sums for each Point a fixed months depending on the date (30 days for 1 month, 90 days for 3 months, etc.). So I can get an alert when any record in Stability reaches the due date (initial date + point time).
Any ideas? Tks

2 Replies 2

I kept digging a little more and tried another way. I used automations in Airtable:

  • when a record is created in (trigger)
  • script
  • create record in Stability

The trick here is the script, a JS loop for an array given an input data (Points in my case). So it should work as for each value in the array of Points, repeats the create record action. This script works ok in Zapier but when copying in AT, gives an error. Any suggestion? I’m copying the script below. In AT I’m using as input variable, referring to the field of the step 1.

// get Input Data field names
let keys = Object.keys(inputData)
let data = ;

// loop through each Input Data field
for (let key of keys) {
// split the contents of each Input Data field on the commas into an array
let li = inputData[key].split(",");
for (let i=0; i<li.length; i++) {
if (typeof data[i] === “undefined”) data[i] = {};
data[i][key] = li[i];
// add a record number (in case we want to break the fork/loop with a Filter)
data[i].recordNumber = i+1;
}
}

A script from Zapier won’t work unmodified in Airtable. It’s been ages since I’ve glanced at a script in Zapier, but I believe that the inputData variable that’s referenced several times is a predefined variable containing data from the previous Zapier step. Passing data into an automation script action is done in a more controlled way with a system that lets you define precisely want you want the script to use. There isn’t a predefined variable that contains all incoming data automatically.

Along that line, you said:

…but that statement is missing something. What exactly are you passing from the trigger step? If you can share a screenshot, that would be the easiest way to see what’s happening.