Best answer

How can I create an array of strings from a comma-separated string

  • 27 April 2021
  • 5 replies

Userlevel 2

I’m creating a Zap to post a field that is coming in from Google Sheets as a comma-separated string, to my app’s API that expects an array of strings.

In Zapier Developer, I test it by keying in a comma-separated string and it works fine with a payload like this:


But in the Zap, I keep getting error: The app returned "activityTypesWillingToDo must be an array of strings".

I’ve tried Transforming from String to Line-Item, I’ve tried javascript to turn it into an array:

const { lineItemEasy, } = inputData;

const lineItemEasyArray = lineItemEasy.split(',');

output = [{ lineItemEasyArray, }];

And I’ve tried actually hard-coding the array of strings into the input field of my Action.

Please help!



Best answer by GetUWired 27 April 2021, 19:44

View original

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

5 replies

Userlevel 7
Badge +12

What API are you using? 

What does your code look like or the input fields? 

If you have the items in an input field called “activityTypes” you can use the following code to check if the value is an array and if not split it into one. 


let lineItems = [];

if (Array.isArray(bundle.inputData.activityTypes))
lineItems = inputData.activityTypes;
lineItems = bundle.inputData.activityTypes.split(",");


Userlevel 2

@GetUWired The API I’m using is in my company’s commercial software app documented here.

I currently don’t have any code on the input field itself.

The code you gave, would that go in a  Run Javascript step in the Zap? Or would that go in the back end integration setup (which I’m currently not using custom code there)?

Userlevel 7
Badge +12

It can go into the backend integration. And it is assuming the input field key for “activityTypesWillingToDo” is just activityTypes.

The input field can also be configured to allow multiple multiples.

I hope that helps !

Userlevel 2

Hi @jeffernst were you able to get this resolved? Let us know how it goes!

Userlevel 2

@Matt_Boyden Yes, thank you @GetUWired , that did the trick.