Oct 06, 2020 11:43 AM
I have a Zap that includes running Javascript in response to a trigger. Specifically, when a record enters a view in the project table, the zap adds tasks for that project into the task table. Here’s what the Zap screen looks like for the Run Javascript action:
Input Data
csString 1. Task Record IDs: record id…record id…
Code
//this code is required to turn the string containing record IDs into
//an array of objects. Because the output is an array of objects the following
//steps will run for each record found.
if (inputData.csString == null) {
var listArray = ;
} else {
var listArray = inputData.csString.split(",");
}
var output = ;
var arrayNos = listArray.length;
var i=0;
do {
var thisItem = new String(listArray[i]);
var thisItemObj = {};
thisItemObj.record = thisItem;
output.push({thisItemObj});
i++;
}
while (i < arrayNos);
I’m trying to recreate this Zap using Airtable automation. Step 1, of course, is the trigger. In Step 2, I chose a “run script” action. I pasted the above code into the code pane (center of the “edit script” screen), but need help with the left “Input variables” pane. There are 2 fields in that pane, Name & Value. What should I specifically put into those fields? I’ve tried a few different things, but keep getting a syntax error: “Cannot find name ‘inputData’.(2304)” .
Thank you!
Oct 06, 2020 12:14 PM
Hi @Jody_Bruce - my advice is not to start with the Zapier script. Although both Zapier and Airtable can use JS, the data you have access to and the methods (in Airtable) are going to be different. I think you would be better off starting from scratch in Airtable.
I wrote a post about scripting a similar thing here:
This doesn’t use automation, but:
Oct 06, 2020 12:57 PM
Thanks, I will check this out!