Using a Run Javascript action from Zapier in Airtable Automations

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…

//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;
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!

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:

  • It could be converted to an automation script easily
  • It will give you an idea of the script approach that could be used in Airtable.
1 Like

Thanks, I will check this out!

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.