Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Journal Entry value shows up without blank lines/paragraphs

AdamUMC
Tera Guru

Hi there,

I'm using email script, (a part) shown here below, to print the last given "Additional Comment" within a Incident, in an system notification (email).

template.print('<p><span style="color: #ffffff; font-family: trebuchet ms, geneva; font-size: 10pt;"><strong>');
template.print(journalEntry.value);
template.print('</strong></span></p>');


This works so far, so good. The only problem that no blank lines/paragraphs are shown in the generated email. All text is strung together.

How can I solve this problem. I've already tried something as here below, but unfortunately, that does not work. There must be an solution for this problem.

template.print('<p><span style="color: #ffffff; font-family: trebuchet ms, geneva; font-size: 10pt; p {margin-bottom: 10pt;}"><strong>');
template.print(journalEntry.value);
template.print('</strong></span></p>');


What I get:
find_real_file.png

What I want:
find_real_file.png

Any solution would be appreciated! Thanks!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Use the global setting. Something like:

journalEntry.value.replace(/\n/gm, "<br/>")

 

P.S. or /\\n/gm, "<br/>" as regex expression (cant test it atm, sorry 😞 )

View solution in original post

8 REPLIES 8

Community Alums
Not applicable

Use the global setting. Something like:

journalEntry.value.replace(/\n/gm, "<br/>")

 

P.S. or /\\n/gm, "<br/>" as regex expression (cant test it atm, sorry 😞 )

Wow! This works! Thanks a lot, I appreciate!!

P.S.: From where do you get this knowledge? I'm searching here and there, but am still not able to solve this type of things in my own. I have to say, my Javascript knowhow is practically zero; I just started learning through topics like these.

Community Alums
Not applicable

Glad I helped a bit 🙂

Well, it's standard RegEx and JS. You can do few free courses to get a better grasp on it (or best paid on Udemy for example, there are very good ones)

Here are link for a free and a paid one :

https://javascript.info/structure

https://www.udemy.com/course/modern-javascript-from-the-beginning/?ranMID=39197&ranEAID=jU79Zysihs4&ranSiteID=jU79Zysihs4-yOhYk4_7A6wvJtqr3eEicA&utm_source=aff-campaign&utm_medium=udemyads&LSNPUBID=jU79Zysihs4

Hello Joro,

Thanks a lot!