Replace Blank/Empty/Null Values in Array with Default Value Using Code

  • 28 March 2022
  • 3 replies
Replace Blank/Empty/Null Values in Array with Default Value Using Code
Userlevel 7
Badge +14

📌  We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy users.

How to Configure

Copy the Code

let Set = inputData.Set.split(","); // split array into line items by the comma delimiter
let Default = inputData.Default; // default value to set for blank/empty/null items

// FOR loop to iterate over each array item
for (let i = 0; i < Set.length ; i++) {
if (Set[i] == "" || Set[i] == null) {
Set[i] = Default; // sets default value

output = [{Set, Default}];

The Results


Contribution by Troy Tessalone

Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 4
Badge +1

Hey @andywingrave,


Just wanted to tag you as this appears to be another solution, compared the one I found here. I wasn’t sure if you had seen this post, but I thought it’s a great reference!


And of course, I know you’re a master of JS, Zapier and other languages! Thanks for all the awesome work you do! <3 

Userlevel 7
Badge +9

Thanks @Lionel_Selie 

I don’t understand the context. I can read and write JavaScript, Zapier 🙃 and English, but I think for this to be an article, it needs more context and more of an explanation as to what is happening, why it is happening and why solving the problem is a good thing. 🙏

As Wikipedia would say

“This article is a stub...” 😜






Userlevel 4
Badge +1

This is a great solution! Thanks so much for sharing this!


cc: @andywingrave