I wanted to share this code tidbit because it took me hours to work out what was happening. It has to do with where the zapier Javascript is expecting semi-colons, especially in looping.
My code takes comma-delimited input variables, splits them into arrays, and then puts the elements of the array back together to return JSON. Notice especially where the semi-colons are, since either leaving them out or putting them in the wrong place will cause the Zapier action to fail. Code:
var descrline = inputData.descrline.split(',')
var qtyline = inputData.qtyline.split(',')
var refline = inputData.partrefline.split(',')
let gChildren = ]
var i = 0 ;
for(i; i < descrline.length; i++){
gChildren.push({description: descrlineei], quantity : qtylineei], partReference: reflineei]})
}
return {gChildren}
referring to these 2 lines:
var i = 0 ;
for(i; i < descrline.length; i++)
Normally, in JavaScript, I would put them in one line like this:
for(var i = 0 ; i < descrline.length; i++;)
In Zapier, you can’t. The declaration of the variable can’t happen in the for clause, it has to be separate.
One other change: no “;” after the “++”
I hope this helps others figure out the syntax of the JavaScript!