Best answer

Formatter: Split Text not including blank values

  • 16 December 2021
  • 6 replies
  • 260 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!)

icon

Best answer by Troy Tessalone 17 December 2021, 16:49

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.

6 replies

Userlevel 7
Badge +14

Hi @PeterCera 

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

Sadly @Troy Tessalone that just gives this:

 

output

1

   1 Clear

2

    1 Clear

3

    1 Clear

4

     1 Clear

Userlevel 7
Badge +14

@PeterCera 

I tried this:

 

And got this:

 

Userlevel 7
Badge +14

@PeterCera 

Or you can use a Javascript Code step like this;

 

 

 

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

 

Userlevel 7
Badge +14

@PeterCera 

Give this Javascript Code a try:

 

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