Join a string with multiple line breaks into one line

Rafaeloneil
Giga Contributor

Hello SN community

I'm trying to create a script that can merge the content of a variable in just one line

myString:

Prxzxdos,


xom dix!


Rxf.: xxixx xxnxfício Trixutário

 

Solicitxmos xxixx dx xxnxfício trixutário do vxículo xm rxfxrêncix pxrx inclusão dx xrxvxmx.


gxSaI:93XHYKL1TPCN55307
RxNxVxN: 01301908433
PLxCx: QLZ6x34
UF: xC

 

This string will basically contain all the text of emails received in my process

When trying to apply commands like index(of) and substring I noticed that I can only use them after leaving the mass of data on a single line

Can you give me some guidance?

3 REPLIES 3

MrMuhammad
Giga Sage

Hi @Rafaeloneil ,

You can try something like this.

var newString = <your_string>.replace(/\n/g, '\n');

Regards,

Muhammad

Regards,
Muhammad

MrMuhammad
Giga Sage

if the Above doesn't help then you can try something like Alikutty suggested on the below link

https://community.servicenow.com/community?id=community_question&sys_id=413ce1e2dbce33405d782183ca96...

Regards,

Muhammad

Regards,
Muhammad

Rafaeloneil
Giga Contributor

None of the mentioned options worked...

The tricky thing is that even trying to do it via the backgroud script my string (with the line breaks)

find_real_file.png

is not accepted by ServiceNow

find_real_file.png