Skip to main content
Best answer

How do I turn multiple field values into a comma-separated string

  • November 22, 2021
  • 8 replies
  • 1275 views

jeffernst
Forum|alt.badge.img

I’ve seen a ton of articles and posts on turning a comma-separated list into separate fields, but none on the opposite. I have text values in five different fields that come from columns in Google Sheets. I want to turn them into a comma-separated string to feed to my API. The challenge is that there isn’t always a value for all five fields, one or more can be empty.

So if I simply do Field1Value, Field2Value, Field3Value, Field4Value, Field5Value in the zap, and Field1 and Field 4 are blank, the result is extra commas like:

, Field2Value, Field3Value,, Field4Value.

Any ideas?

 

Best answer by Troy TessaloneBest answer by Troy Tessalone

@jeffernst 

Try this Code (JavaScript):

 

 

RESULTS

 

View original
Did this topic help you find an answer to your question?

8 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • November 22, 2021

Hi @jeffernst 

This can be done with a Code step: https://zapier.com/apps/code/help


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • Answer
  • November 22, 2021

@jeffernst 

Try this Code (JavaScript):

 

 

RESULTS

 


jeffernst
Forum|alt.badge.img
  • Author
  • Beginner
  • 12 replies
  • November 22, 2021

@Troy Tessalone just saw your sample, let me try with that.


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • November 22, 2021

@jeffernst 

See Code above.


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • November 22, 2021

@jeffernst 

Here’s another option

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • November 23, 2021

@jeffernst 

Did you get this to work?


jeffernst
Forum|alt.badge.img
  • Author
  • Beginner
  • 12 replies
  • November 23, 2021

@Troy Tessalone This worked perfectly, thank you so much, I will be using this in many zaps. You rock.


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30948 replies
  • November 23, 2021

@jeffernst 

Consider using Sub-Zaps to share common Zap actions across other Zaps: https://zapier.com/apps/sub-zap-by-zapier/integrations#triggers-and-actions