Journal Entry value shows up without blank lines/paragraphs

AdamUMC
Giga 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

Allen Andreas
Administrator
Administrator

Hi,

Have you tried using:

current.comments.getJournalEntry(1)

I believe same can be done directly in your notification body, without a mail script such as:

${current.comments.getJournalEntry(1)}

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello Allen,

Thank you for your reply. Yes, I've tried this, but the problem using this attibute is that the text font, format, etc. are hard to change to something else than the default "Journal Entry" style.

Yes I have tried various solutions. Please see topic: https://community.servicenow.com/community?id=community_question&sys_id=7027e17c1b99c51038739979b04bcb84 (see post 6 viewed from top to bottom).

Community Alums
Not applicable

Try replacing \n (new line) with <br/>. Maybe something like :

template.print(journalEntry.value.replace("\n", "<br/>");

Thanks, but unfortunately, this does not work for 100%. The first sentence is now shown on a new rule, but without blank line/paragraph inbetween the next sentence.

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