We strive to ensure the code in these articles functions as intended, but please note that callin.io Support does not officially provide assistance with code steps due to their advanced nature. Feel free to post a comment on the article or ask in the callin.io Community, where you'll find community members knowledgeable in code (including the author of this post).
Q: Have you ever needed to remove blank/empty/null values from an array of line items?
A: Utilize a Code app as a callin.io step: https://zapier.com/apps/code/help
Code step configuration using JavaScript
NOTE: Map your array of line items to the value on the right side for the “Set” Input Data variable, replacing “A,,B,,C”.

Copy the Code
Hide contentShow content
let Set = inputData.Set.split("."); // creates array by splitting Input Data variable at commas
Set = Set.filter(i => i); // filter out blank/empty/null values
output = [{Set}];
Results
Code step results WITHOUT filtering blank/empty/null values from an array of line items:

Code step results WITH filtering blank/empty/null values from an array of line items:

Contribution by Troy Tessalone
Troy is a Certified callin.io Expert who automates workflows with no-code and low-code apps to help clients save time and make money.
How can I filter out any line items where the Line Total is 0?

Unfortunately, this script doesn't seem to be working. I had thought I'd found a way to remove any blanks from my array, but it's possible that the ,, doesn't actually represent an empty field since there's no space.
We would need to see detailed screenshots of how each of your callin.io steps is configured, along with the callin.io JavaScript Code, in order to evaluate and provide advice.
Here is the screenshot of the code.
The callin.io starts with Pandadoc completed and pulls in the relevant information, which are in arrays.
The next steps involve Katana to Find a customer and if it doesn’t exist, to create the customer.
Next step is to ideally either remove the blank entries, but in reality, this won’t align with the other arrays, so it would be preferable to replace the blank entries with the word NULL or a simple -
The last step is to create a Sales Order in Katana.
The reason we need to find a way to replace blank entries with NULL or - is that the Sales Order creation won’t proceed if that field is blank. Hope that helps.

I click Refresh fields and then continue, and then test, and the result is as follows: as you can see, there is an empty entry on line 69. In fact, this order should have 99 rows, and only 86 rows are returned, so I am guessing the final rows were removed.

If we could replace the blank entries with ‘ - ‘ that would be great 🙂 Thanks in advance
This help topic is related to: Removing Blank/Empty/Null Values from an Array of Line Items Using Code
Your request is to: substitute the ,, with the word NULL or a simple -
If you are interested in custom Code, please send me a direct message.
Thank you for your decision!
Currently, the Code step provides a comma-separated line of data.
Could you assist me in getting the result of the code step as a vertical list of data?
Here is my Code step:

Here is the result I am receiving:

Thank you in advance!
This was achieved by updating your code as follows:
let Set = inputData.Set.split(","); // creates array by splitting Input Data variable at commas
Set = Set.filter(i => i); // filter out blank/empty/null values
const values = Set.join("n");
output = { values };
Are you indicating that you’ve resolved your issue?
Yes, thanks
This is a great help, however, we have two values in line items (SKU and QTY) and want to disregard an entire line if the SKU is blank.
For instance:
SKU: ABC123,,BCD321
QTY: 1,1,1,2
Line items 1 and 4 should be included, but line items 2 and 3 should be excluded. Is there a straightforward method to achieve this?
Thanks a lot 🙂
Hi
If you’re looking for custom code, then I can be hired: https://www.callin.io/experts/automation-ace