Help

Re: Using a Run Javascript action from Zapier in Airtable Automations

1409 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Jody_Bruce
5 - Automation Enthusiast
5 - Automation Enthusiast

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!

2 Replies 2

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.

Thanks, I will check this out!