How to print worknotes in same line?

Gayathri5
Tera Guru

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.

 

1 ACCEPTED SOLUTION

Appli
Mega Sage
Mega Sage

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

Hope it helps

View solution in original post

5 REPLIES 5

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Gayathri5 ,

Use below Line to print worknote :-

rtask.work_notes ="Change " +current.number + " has been cancelled.\n" + "Work notes: "+ onlywn.replace(/\n/g, "")

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy