- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 06:06 AM
Hi All,
I used this below code for adding note in comment field but "\n" is not giving new line in comment field.
Please let me know any issue in this script
var comments_ritm = " This case has been created from "+number;
var comments = current.comments.getJournalEntry(-1);
ca.comments = comments_ritm+"\n\n"+comments;
Thanks,
Neethu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2017 01:12 AM
The issue got fixed by using following script
var number= gs.getMessage(["[code]<a href =sc_req_item.do?sys_id="+ current.sys_id +">"+ current.number +"</a><p>[code]"]);
var comments_ritm = " This case has been created from "+number;
var comments = current.comments.getHTMLValue();
ca.comments = comments_ritm+comments;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 06:13 AM
Hi Neethu,
I just tried the following from scripts background on one of my incidents and it respected the \n\n. Can you verify.
var inc = new GlideRecord('incident');
inc.get('85071a1347c12200e0ef563dbb9a71c1'); // Use a sys_id of one of your test incidents
var com = 'This is a comment\n\nwith multiple lines\n\nwritten in scripts - background\n\n';
inc.comments = com;
inc.update();
If it works, then we know there might be something with your script. More context is appreciated - for example, did you get any errors? Is there more to the script than what is shown? Did it add any comments and just not add the \n\n?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2022 07:14 AM
This definitely works! After scouring the community this did the trick! Thanks Chuck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 06:14 AM
Hi Neethu,
From where you are updating the comments?
Is it from business rule or some other server side script?
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 06:17 AM
I am updating it from UI Action