Best answer

Flattening or convert multi line input into a single line

  • 12 April 2020
  • 2 replies
  • 1446 views

Userlevel 1

Hi All

 

I have a multi-line input that I need to convert or flatten to a single line for use in a different field.  I would need to adda space at least between each line for the output to make sense though. I thought the formatter > Text action would have something, but none of the options seemed to be what I needed.  Any thoughts on how to accomplish this? 

icon

Best answer by ikbelkirasan 12 April 2020, 04:34

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.

2 replies

Userlevel 7
Badge +12

Hi @kstamm - Try using a JavaScript code step. Make sure to pass the text in an input field called “text”.

const text = inputData.text
.split("\n")
.map((line) => line.trim())
.join(" ");

output = [{ text }];

 

Userlevel 1

Just what I needed, thank you Ikbel!  Those code steps can do a lot if you have the knowledge.