it's been several times that I got stuck with this one: I don't understand how to output Line-Items with a Code step?
Is it even possible?
For example:
I build Line-Items from a JSON
In these Line-Items, I would like to remove some of them, based on various criteria
Then output Line-Items and use them in a further step
Here is something I tried:
But, on a further step, I don't get Line-Items but separate values:
So, how to manipulate Line-Items into a Code step and get Line-Items as the output?
I feel like I'm missing something...
Thanks,
Alex
PS: more explanation on the "why".
I got my data from a Typeform entry in which I can get between 1 and 5 emails (plus other data)
So, I got empty row that I want to remove
That's why I build a Line-Items object then try to remove the useless ones
Best answer by ikbelkirasan
Hi @AndrewJDavison_Luhhu and @Ulule
@Ulule - You are currently setting the output to something like this:
[
{
0: {
email: "...",
address: "..."
},
1: {
email: "...",
address: "..."
},
2: {
email: "...",
address: "..."
}
//...etc
}
];
However, what you're looking for is something like this:
[
{
items: {
0: {
email: "...",
address: "..."
},
1: {
email: "...",
address: "..."
},
2: {
email: "...",
address: "..."
}
//...etc
}
}
];
Or this:
[
{
items: [
{
email: "...",
address: "..."
},
{
email: "...",
address: "..."
},
{
email: "...",
address: "..."
}
// etc
]
}
];
As you can see, the output should be an array that contains a single object that has key (called items here but it could be anything) which has an object or an array as a value.
So in order to output line items, you should change the last line in your code to:
output = [
{
items: output
}
];
Hope this helps.
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.
@Ulule - You are currently setting the output to something like this:
[
{
0: {
email: "...",
address: "..."
},
1: {
email: "...",
address: "..."
},
2: {
email: "...",
address: "..."
}
//...etc
}
];
However, what you're looking for is something like this:
[
{
items: {
0: {
email: "...",
address: "..."
},
1: {
email: "...",
address: "..."
},
2: {
email: "...",
address: "..."
}
//...etc
}
}
];
Or this:
[
{
items: [
{
email: "...",
address: "..."
},
{
email: "...",
address: "..."
},
{
email: "...",
address: "..."
}
// etc
]
}
];
As you can see, the output should be an array that contains a single object that has key (called items here but it could be anything) which has an object or an array as a value.
So in order to output line items, you should change the last line in your code to:
@ikbelkirasan thank you so much for your answer, yeah it solves my issue!
So basically I need to "re-build" a new set of items.
Zapier Support had answered as well and they gave me the same answer about the Output that must be an array.
Thank you again!
The Zappy Awards are back
We're celebrating the Zapier builders making AI transformation happen. Winners get a published story on zapier.com, a trophy, $5,000 cash, and a feature at ZapConnect. Nominate yourself or a peer by July 24th, 2026.