multi line text field variable adding to notification with formating

Bidduam
Tera Guru

I have a variable that is a multi line text field.

When someone enters text into it, that they have formatted into separate lines eg: 

This is my text line 1.

This is my second line.

The third line.

 

When that gets passed into a notification for instance, it loses all formatting and gets added as a single line, such as:

This is my text line 1.This is my second line.The third line.

 

Any ideas of how to make it appear as separate lines?

 

Anyone else?

 

5 REPLIES 5

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Bidduam ,

 

I am not sure if there is any direct way or a easy way to do this like with a single command but what u can do is while fetching the variable from multi line text split by ('\n') . Then while adding it in ur notification u can make use of email script run a for loop & print it. Just a suggestion

 

Thanks,

Danish

Aman Kumar S
Kilo Patron

Hi @Bidduam 

The challenge is when you are pulling the value, it is passing of line breaks as ('\n'), but when it comes to the Rich HTML editor, it doesn't recognize this and expects ('<br>').

My suggestion would be to create an email script, to replace the '\n' with '<br>'

To understand the behavior better, give below article a go:

https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/administer/notification/concept/c_...

 

Best Regards
Aman Kumar

@Aman Kumar S 

This isn't coming through with /n in it to start with I don't believe. So nothing to replace.

 

It's just plain text. Is there a way to say after every full stop to add a new line or something before adding the next bit of text?

 

For example I tried this and it obviously hasn't worked, but is it on the right track at all or am I just not even close?

 

var newline = current.variables.question10.replace(".", "\n");
template.print('<li> ' + newline + '.<br>');

 

Can you check in the HTML editor, if those tags are coming in, once you place the field in the body.

Full stop can also be the option, but I believe that is not a good delimiter, not every line should end in full-stop and who is going to enforce that for end users.

Best Regards
Aman Kumar