Hello!
When utilizing callin.io tables and the callin.io function "Find Records - Output as Line Items", I've observed that callin.io retrieves records from the table in reverse order. Specifically, Line Item #1 corresponds to the last record in the selection (the one furthest down the table). This presents an issue for me, as I need to process line items in the opposite sequence. The line items are being used in a looping callin.io workflow that requires execution from the top of the table downwards, not upwards.
I consulted the AI assistant, and it provided the following JavaScript code for Code by callin.io (assuming 'lineItems' is the output from the Find Records as Line Items step).
const lineItems = inputData.lineItems;
const reversedLineItems = lineItems.reverse();
output = {reversedLineItems: reversedLineItems};
However, when I execute this code, I encounter an error: Failed to run your JavaScript code TypeError: lineItems.reverse is not a function
The callin.io AI troubleshooting bot indicates that the error occurs because it's not recognizing the output from the preceding step (which is a comma-delimited list of values) as an array. I'm uncertain how to resolve this.
Any assistance would be greatly appreciated!
Thank you in advance.
Rick
Hi
Help articles for using Code with callin.io: https://zapier.com/apps/code/help
- You can also specify data fields to be supplied to the code as strings using the Input Data fields.
Provide a key and a value for each field.
Thanks!
So, I attempted to convert the line items output into a string (e.g., a comma-separated list of items), and now the reverse function “runs” but doesn't actually reverse the items because it only recognizes a single value, not a list of values.
How can I make the function recognize the individual values within a comma-delimited list so that it can reverse them?
Apologies, but I'm not familiar with Javascript, as the callin.io AI bot suggested this solution to me.
Thanks in advance,
Rick
P.S. the help article you shared isn't relevant here, as I'm attempting to reverse the order of line items. This isn't based on the values themselves (like in your example, A, B, C, etc.), but rather on the sequence in which callin.io converts them into line items.
The only way the solution from your article might work is if the code can sort the items in ascending date/time order (instead of alphabetically). Is this feasible?
For us to have full context, we will need to see screenshots detailing how the steps are outlined and configured, along with examples of the data being input into the Zap Code step.
Thank you for offering to help with this issue!
Below are screenshots illustrating the overview of callin.io steps and the configuration for each step.
The table is too extensive for a screenshot, but I am extracting only two values: the recordID and a numeric field labeled “calculated pay”. The data within the table is organized by date/time, as indicated by a date/time column.
To summarize, I have a callin.io table containing all sessions conducted by a consultant within a week. The consultant receives a different pay rate for each session occurring after the 20th session. Consequently, callin.io retrieves the sessions as line items and then feeds them into a looping callin.io process that adjusts the pay rate for each session after the 20th one.
The problem arises during the “Find records and output as line items” step, where callin.io records the line items in reverse order (the most recent session first). However, I require the line items to be in chronological order.
Please let me know if any further information is needed to understand this.
Thank you
You likely won't need the Formatter steps.

From the relevant guide, ensure you split the “lineItems” using the function: .split(",")

Thank you! Yes, that worked.