How to add linebreaks while defining a rich text field via script?

Zod
Giga Guru

HI Coding Guys ... just an easy one I hope ...

Want to full a description field by using values of different fields ... so I need linebreaks.

new_description = ("Label 1: " current.field1+ LINEBREAK +"Label 2: " current.field2 + LINEBREAK + ...);

The new_description field is rich text .. so if we could also BOLD the Labels ... that would be cool 😉

Thank you!!

1 ACCEPTED SOLUTION

new_description= ("<b>Label1: </b>"+current.u_lable1+ "<br><b>Lable2: </b>"+current.u_lable2);



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

darius_koohmare
ServiceNow Employee
ServiceNow Employee

Have you tried sending in an encoded newline character?


new_description = ("Label 1: "+ current.field1+" \n Label 2: " current.field2 + "\n"+ ...);


SanjivMeher
Kilo Patron
Kilo Patron

Try below



new_description = "<b>Label 1: </b>" current.field1+ "\n<b>Label 2: </b>" current.field2 + '\n';



Please mark this response as correct or helpful if it assisted you with your question.

Zod
Giga Guru

BOLD works .. not the linebreak does not ... trying:



new_description= ("<b>Label1: </b>"+current.u_lable1+ "\n<b>Lable2: </b>"+current.u_lable2);

new_description= ("<b>Label1: </b>"+current.u_lable1+ "<br><b>Lable2: </b>"+current.u_lable2);



Please mark this response as correct or helpful if it assisted you with your question.