Skip to main content
Best answer

Formatter: Split Text not including blank values

  • December 16, 2021
  • 6 replies
  • 333 views

I am trying to use Formatter to split a string of 6 test responses and have encountered the problem that if a test is not complete, the value is empty. So a typical response might be:

 

clear, clear, , ,clear, clear

I need the response to be:

0: clear
1: clear
2: 
3:
4: clear
5: clear

But instead I just get 1-4 = clear

Any ideas on how to solve for this within formatter, or is there a code alternative (am not really a coder!)

Best answer by Troy Tessalone

@PeterCera 

Give this Javascript Code a try:

 

The code returns a Set object with each option as it’s own data point.

 

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

6 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • December 16, 2021

Hi @PeterCera 

Try using Formatter > Utilities > Text to Line Items: https://zapier.com/help/create/basics/use-line-items-in-zaps


  • Author
  • Beginner
  • December 16, 2021

Sadly @Troy Tessalone that just gives this:

 

output

1

   1 Clear

2

    1 Clear

3

    1 Clear

4

     1 Clear


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • December 16, 2021

@PeterCera 

I tried this:

 

And got this:

 


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • December 16, 2021

@PeterCera 

Or you can use a Javascript Code step like this;

 

 

 


  • Author
  • Beginner
  • December 17, 2021

Hi @Troy Tessalone this is great thanks, an works - but when I go to plug in a response into a google sheet update lower down the Zap, the field available to me from the code step still reads like an array of Result (Clear,clear,,clear,clear) - I can’t figure out how to, for example just extract the 5th item (“Clear”) which corresponds to the field I’m trying to populate. Thanks so much for your thoughts

 


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • Answer
  • December 17, 2021

@PeterCera 

Give this Javascript Code a try:

 

The code returns a Set object with each option as it’s own data point.