Add line breaks on email

Prudhvi Raj4
Tera Guru

Hello Team,

I have requirement is to copy the catalog variable field value into the email notification sent out, but here the agent use to copy/paste the text to this variable and I need to add line break for the text added to the field and sent it into the email. For example user pasted below text to the field 

TK7Y-N3BY-DMV4-NBGW-NRD5-JWMQ Acrobat ALL DRI01
D4YF-VC7X-ZCBY-DEOP-OQU6-W4MV Acrobat ALL DRI01
TRHU-WGCZ-GD3B-93CZ-TVNU-WNX9 Acrobat ALL DRI01
APPK-6NW6-4A5K-7AWG-KOP6-Z5A4 Acrobat ALL DRI01
EMNK-DBE5-HHP4-X667-YZNH-7CCE Acrobat ALL DRI01
DWPR-VXZJ-NWPG-OBN7-QH9M-9NDF Acrobat ALL DRI01
XNWG-TKWW-YDZR-6WPY-KRFK-DHJ9 Acrobat ALL DRI01
ZN4E-4XKY-A557-DHBK-ETZX-GBCX Acrobat ALL DRI01
5B6R-GOAV-RZWZ-4TQX-ZUCG-XWUA Acrobat ALL DRI01
C9VN-ZFOJ-NNHJ-ZKUO-5WTN-P3KY Acrobat ALL DRI01
7AKP-3MNN-59QK-YBRH-DKVN-FGTA Acrobat ALL DRI01
XAY5-7JAV-UQJF-EPTA-N5WE-9MDQ Acrobat ALL DRI01
QF5F-O4KF-5F3Z-CADO-Q9WZ-H53V Acrobat ALL DRI01
WX7N-7O95-TYVN-6CPT-35BR-ADUF Acrobat ALL DRI01
BURQ-HO4C-KKUK-Z5GQ-W53C-DYYZ Acrobat ALL DRI01
6VRB-XCKV-4ROO-BW3E-BGKO-4X3K Acrobat ALL DRI01
TUUG-MW6Y-YJ9V-NKGA-GAX5-OJOH Acrobat ALL DRI01
FQNM-Q5XR-OPTM-5YW5-TXKB-PX4B Acrobat ALL DRI01
DVBZ-HCBR-G4OT-4CYG-XYN9-OWH4 Acrobat ALL DRI01
GXGW-DXCD-4RPO-DDB4-6WOT-3KW6 Acrobat ALL DRI01
TDP9-7WPE-7ZV7-NXGA-4GHE-JGPW Acrobat ALL DRI01
3944-WJFP-QVOT-REOA-KC5Q-D4PH Acrobat ALL DRI01
JBJR-AMCF-UGPR-HFKB-RWET-4KFY Acrobat ALL DRI01
QRNF-QPRY-AJOT-7KN7-67QJ-6ME5 Acrobat ALL DRI01
VQ4V-ZYXT-7B5M-H7FF-N3DF-PEN4 Acrobat ALL DRI01
6Y77-7JCR-XM45-CXEJ-VOZD-GZQJ Acrobat ALL DRI01
XDYX-HVJK-HBXJ-FMPW-CV9E-WDZQ Acrobat ALL DRI01
TRYD-43DT-NQAA-TMNY-RYQM-YKOA Acrobat ALL DRI01
XAX7-53QP-THFN-59P6-DWOK-MVF6 Acrobat ALL DRI01
UNXA-3B7H-CQAC-NTWY-VRNQ-MY74 Acrobat ALL DRI01
5XCE-ZCP3-FM56-XNQ6-WOXO-H53G Acrobat ALL DRI01
9ENZ-N63X-EAWB-OOZ4-74MB-X7CV Acrobat ALL DRI01
WEG6-EHOC-JNOF-YB53-HNTO-YNHF Acrobat ALL DRI01
BPMC-UTYY-C364-PTRG-V6DG-XKKK Acrobat ALL DRI01
AQW5-6RVZ-GEFK-5XRT-5M5G-XCFU Acrobat ALL DRI01
5EVA-YRDV-EZD9-DA4C-EWZY-WB4O Acrobat ALL DRI01
3OOM-A7KQ-MB3Y-GJ3N-GPFM-W3BB Acrobat ALL DRI01
ZU3F-VXQN-G5ZM-7V75-CMBF-WNHP Acrobat ALL DRI01
TBPE-9FPG-EONH-K9BT-WU69-DOHG Acrobat ALL DRI01
KUTU-3JWH-QN43-X46Y-CKWT-6W4Q Acrobat ALL DRI01
AXN6-AQDH-7EVZ-5JWV-3EY5-3MDD Acrobat ALL DRI01
KBGG-Z6OE-9FJK-5R45-6CVQ-96AK Acrobat ALL DRI01
3966-KORR-URAZ-RH57-WZHF-FZKT Acrobat ALL DRI01
7U6F-JNRB-BO65-EWWK-V6KV-XG5Y Acrobat ALL DRI01
F6ZN-NPWG-BRB4-BEMX-Y3DY-RA9K Acrobat ALL DRI01
EYQZ-KYPJ-3WD7-VZZU-X5XY-7XVO Acrobat ALL DRI01
TVQE-PACQ-JWD9-WDHF-VF5Y-JDJB Acrobat ALL DRI01
YMT4-JZTD-C45W-GDGD-ARFG-Z9MW Acrobat ALL DRI01
VWD9-QWGY-F7KT-VQ6H-6O6X-DT9Q Acrobat ALL DRI01
GZTE-PC4M-9QMW-R54G-JT7Y-GOKB Acrobat ALL DRI01

 

 

 But email something goes like this

PrudhviRaj4_0-1695192125404.png

So I want to add every code in new line as there is comma in the copy/paste text it considers at one text but it's not I need to line breaks here, please suggest.

 

Thanks,

Prudhvi 

5 REPLIES 5

Venkatesh_N
Tera Guru

Hi @Prudhvi Raj4 ,

Using a mil script, First split the value into array based on comma in the text.
Use array.split(',')

Next, initiate a for loop to join with a new line string like below
var field value = '';

for(var i in array){

field value = field value +  " \n "  + i;

}

 

Now insert the field value in the notification.

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks,
Venkatesh Nekkanti

Hi Venkatesh,

Issue here is agents are pasting text which doesn't contain comma, if comma is there it's simple to break but without comma they are just going to new line 

Sagar Pagar
Tera Patron

Hi @Prudhvi Raj4,

 

For new line in email scripts you can use either

template.print("<br />");

OR

template.print("%0D%0A");

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Ankur Bawiskar
Tera Patron
Tera Patron

@Prudhvi Raj4 

you can use script shared by other members.

but I am concerned since user is copying and pasting information, user can add any information in that variable

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader