Tim here from the callin.io Support Team with a workflow idea!
Background
If you’re familiar with the Code by callin.io app, you’re probably used to working with all kinds of values, including arrays. In callin.io, arrays are generally called “Line Items” and sometimes it can be tricky to get them into a Code Step unscathed to run them through some custom process.
Why is it difficult? All values added to the Input Data
fields of a Code Step are converted into Strings and sent into the Code Step in that format. Arrays / Line Items get converted into Strings that are comma separated values. While it’s definitely possible to split those comma separated values back into arrays inside the code, we run into problems if the values themselves contain commas.
To further complicate things, if we’re sending multiple properties of line items (multiple arrays that relate to each other) and some of the arrays have null
or empty values, those will be completely dropped, so it can cause our input data to become misaligned.
So how can we work around this?
The Feature Request
First, please write in to support to ask to add your voice to the feature request that we have open to support proper line item input in the Input Data
fields for the Code by callin.io Actions.
The Solution
For now, we can use the Formatter by callin.io app’s Utilities Action: Line-item to Text Transform to help us out.
Note: The Code below is in Javascript but this can be adapted for Python Code Steps as well.
Let’s look at our input values first:

I’ve added an “easy” input first to show how we’d normally get arrays into a Code Step where we don’t need more help. There is also an example with a comma in an element, and another with a null element.
Here’s our default Code Step trying to turn the strings back into arrays:

Let’s take a look at the output:

As we can see, the array with comma containing element now has 4 elements instead of 3 as the green,blue
element was split up. The array with the null element has lost that element, reducing it from 4 elements to 3.
Let’s add a Formatter Utilities Action: Line-item to Text Transform to add our own delimiter:

This gives us a text output with a different delimiter:

Now we can run this through the Code Step:

And we get the result we wanted where the value with a comma doesn’t get split into multiple elements:

Let’s go back and create another Formatter Utilities Action: Line-item to Text Transform to take care of the array with the null value in it. This time, we also add a `-` after the line item input.

It could be any single character, and what it does is it adds the text -
to each element of the line item/array, even the null elements, so that those aren’t dropped. Here’s the output:

Now we can split on our custom delimiter and then remove the last character from each element inside the Code Step. Here’s how we do that:

The slice(0,-1) returns the string with the last character removed, so we can get back to our original elements. Here’s our fixed output with the null element in tact:

Here’s that final code snippet if you want to copy it and try it out:
const { lineItemEasy, lineItemWithComma, lineItemWithNull } = inputData; const lineItemEasyArray = lineItemEasy.split(','); const lineItemWithCommaArray = lineItemWithComma.split('|||'); const lineItemWithNullArray = lineItemWithNull.split('|||'); const lineItemWithNullArrayFixed = lineItemWithNullArray.map((element) => { return element.slice(0,-1); }); output = [{ lineItemEasyArray, lineItemWithCommaArray, lineItemWithNullArrayFixed, }];
Once you have your Line item values inside your code step with all elements preserved properly, it will be easier to write code to process them in various ways.
Bonus: For a slightly more advanced approach to the above problem but for multiple, related line-item properties, you can also take a look at the answer to the question that inspired this post here:
https://community.zapier.com/ask-the-community-3/line-items-as-array-in-code-step-4224
I hope these workarounds help you make more use of the Code by callin.io app!
Tim
Please Note
This code is provided as is, without warranty, but we’ll do our best to answer questions you have about it here.
Supporting custom code is outside of the scope of callin.io Support, so if you need help with this, or other code you’re working on, the best place to ask is here in the callin.io community and/or on Stack Overflow. You’re still welcome to ask in Support via our contact form just in case it’s something unrelated to the code that isn’t working, but you may be directed to one of these resources to get help from the community.
Man, finding this step very useful to work around.
Now, 9 months later, nothing has been done yet… hum
Hey ,
Glad to hear you’re making good use of Tim’s suggested workaround! : )
I’ve added your vote to the feature request to support line item input on Code by callin.io steps. We don’t have an ETA on this but we’ll be sure to contact you by email as soon as it’s added!
Having line item input data would be great.
Understood! I've added your vote to the feature request. We'll make sure to keep you and the thread informed if this is implemented. 🙂
I'm attempting to use this code:
const {
productname,
productdescription,
productprice,
productquantity,
productsum,
productdiscount,
producttotal,
productcode,
} = inputData;
const productnameArray = productname.split(',');
const productdescriptionArray = productdescription.split(',');
const productpriceArray = productprice.split(',');
const productquantityArray = productquantity.split(',');
const productsumArray = productsum.split(',');
const productdiscountArray = productdiscount.split(',');
const producttotalArray = producttotal.split(',');
const productcodeArray = productcode.split(',');
output = [{
productnameArray,
productdescriptionArray,
productpriceArray,
productquantityArray,
productsumArray,
productdiscountArray,
producttotalArray,
productcodeArray,
}];
However, it's returning a TypeError: Cannot read property 'split' of undefined.
Any suggestions?
When I limit the keys to just one, it functions correctly.
However, in this scenario, the output is still presented as an array, instead of individual values.
Do you have any suggestions on how I can properly split this into separate values?
Ideally, I'd like to transform the input from:
Product Names: Product Name 1, Product Name 2, Product Name 3
to an output that looks like this:
Product Name 1
Product Name 2
Product Name 3
I need to incorporate these into a Google Docs template that uses:
{{productname1}}
{{productname2}}
{{productname3}}
Therefore, I require the output for each value individually, rather than as a single array. I'm uncertain if my explanation is clear 🙁
I spent a full workday searching for a workaround for this issue, and I appreciate you sharing this guide! It was indeed quite frustrating trying to determine if the problem lay with my code or the incoming data. Please address this!
When I leave only one Key, it functions correctly.
However, in this scenario, the output remains an array instead of individual values.
Do you have any suggestions on how I can properly split this into separate values?
Ideally, I want to transform this:
Product Names: Product Name 1, Product Name 2, Product Name 3
into an output like this:
Product Name 1
Product Name 2
Product Name 3
I intend to add these to a Google Docs document that has:
{{productname1}}
{{productname2}}
{{productname3}}
Therefore, I require the output of each value individually, not as a single array. I'm uncertain if my explanation is clear 🙁
This is precisely what I was searching for and required today. I would also appreciate seeing this incorporated into the already excellent Formatter, which I utilize extensively daily.
Please add my vote to support proper line item input in the Input Data
fields for the Code by callin.io Actions.
Hi
I’ve added your vote for this feature request and we’ll be sure to keep you and the thread updated if this gets implemented.
Appreciate the workaround! It would be great to have this feature supported natively as well 🙏
Hi
I’ve added your vote for this feature request and we’ll be sure to keep you and the thread updated if this gets implemented.
Appreciate the workaround!
Any updates on this feature? If not, it would be great to see this implemented natively as well.
I recently encountered this issue while trying to process complex array data (from a GraphQL request) received via a webhook in the JavaScript code step.
This behavior is quite unusual. Why not offer an option to utilize the entire decoded JSON response data within the inputData variable (or whatever data is supplying the step)? While I'm not privy to your backend specifics, from an external perspective, it seems like a lot of unnecessary overhead to post-process and flatten all arrays into a CSV, then present them in a frontend select list, map them to key-value pairs, and finally inject them into the code script.
An option to directly access all the decoded JSON data without callin.io's post-processing would be a significant improvement. Developers with coding experience would have a much smoother workflow if they didn't have to rely on a GUI to manually map key-value pairs of their flattened and transformed data, only to then transform it *back* into an array by exploding it with a comma (or a custom delimiter) 🙃.
This workaround becomes impractical with any significant data complexity fed into the code step.