- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 07:12 AM
Hi All,
In below notes i am trying to copy worknotes from change request to remediation task table, but i am getting worknotes in next line, which i want on the same line like below
worknotes: ABC
Now i am getting for below code
worknotes:
ABC
var rtask = new GlideRecord('sn_vul_vulnerability');
rtask.addQuery('sys_id', current.parent);
rtask.query();
if(rtask.next()){
var onlywn = current.work_notes.getJournalEntry(1).match(/\n.*/gm).join("\n");
rtask.work_notes = "Change " + current.number + " has been cancelled.\n" + " Work notes: "+ onlywn ;
if(rtask.state != '1')
rtask.state = '2';
rtask.update();
}
Much appreciated your help in this context.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 08:53 AM
Hi, please replace
rtask.work_notes = "Change " + current.number + " has been cancelled.\n" + " Work notes: "+ onlywn ;
with
rtask.work_notes = "Change " + current.number + " has been cancelled.\n" + " Work notes: "+ onlywn.replace(/^\n+/, "");
and test again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 08:30 AM
Hi @Gayathri5
Can you update this line
var onlywn = current.work_notes.getJournalEntry(1).match(/\n.*/gm).join("\n").replace('\n','').replace('\r\n','');
Please let me know if it works and if it does, mark the Answer as correct.
Regards,
Gagan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 08:53 AM
Hi, please replace
rtask.work_notes = "Change " + current.number + " has been cancelled.\n" + " Work notes: "+ onlywn ;
with
rtask.work_notes = "Change " + current.number + " has been cancelled.\n" + " Work notes: "+ onlywn.replace(/^\n+/, "");
and test again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 04:37 PM
Hi,
But below line is doing , i want to understand..can you explain?
.replace(/\n/g, "")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 12:31 AM
Hi, sure. It removes leading newline characters from the string.