Hello!
When using Zapier tables, and the Zap function "Find Records - Output as Line Items", I am noticing that Zapier takes the records from the table in the reverse order, meaning that Line Item #1 is the last record in the selection (furthest down the table). This is a problem for me, as I want it to select line items in the opposite order, because those line items are being used in a looping zap that needs to run going down the table, not up it.
I asked the AI assistant, and they gave me the following Javascript code for Code by Zapier (where lineItems is the output of the Find Records as Line Items step).
const lineItems = inputData.lineItems;
const reversedLineItems = lineItems.reverse();
output = {reversedLineItems: reversedLineItems};
When I run this code, however, I get an error: Failed to run your JavaScript code TypeError: lineItems.reverse is not a function
The Zapier AI troubleshooting bot says that the error is happening because it’s not recognizing the output from the previous step (which is a comma delimited list of values) as an array. I’m not quite sure what to do to fix this, however.
Help!
Thank you so much in advance.
Rick