Zapier and JavaScript - Issue with Code Formatting

OBJECTIVE

I have created a form that gathers multiple choice responses in a single line format. I’m utilizing a Code Action in Zapier to process this data and eliminate any empty entries.

MY ATTEMPT

This is an example of the data I have in Zapier: multiple choice selections for categories like movies and fruits.

Here’s the JavaScript code I’m working with:

return {
  Movies: Object.values(inputData.Movies).join('\n'),
  Fruits: Object.values(inputData.Fruits).join('\n')
}

THE PROBLEM

I am encountering an issue where the output displays as a long vertical list of characters instead of a clean list of selected items. Rather than seeing complete words, they appear as separate letters arranged vertically.

What could be causing this issue? I anticipated obtaining a properly formatted list of preferences, but something seems off in how my code processes the data.

This happens because your input data is a string, not an array or object. When you use Object.values() on a string, JavaScript treats each character separately. First, check what your data actually looks like - add a console.log or temporary return to see it. If your Movies and Fruits data are comma-separated strings instead of arrays, you’ll need to split them before joining with newlines. Try using .split(',') before the join operation. That should fix the issue where it’s processing individual characters instead of complete items.

yeah, common mistake. your data’s probably already a string, not an object, so Object.values() is splitting it into individual characters. just use inputData.Movies.split(',').join('\n') instead. skip Object.values() entirely if it’s comma-separated text from your form.

I’ve hit this exact issue before with Zapier form data. Your form’s sending the data as one big string instead of separate objects. When you use Object.values() on a string, JavaScript just grabs each character - that’s why you’re getting the weird vertical display. First thing I’d do is add a debug step to see what raw data your form’s actually sending. Most form builders will send multiple choice stuff as comma-separated or pipe-separated strings. Once you figure out the delimiter, ditch your current approach and try something like inputData.Movies.split(',').filter(item => item.trim()).join('\n'). The filter part automatically kills any empty selections, which sounds like what you wanted anyway.