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

Community Alums
Not applicable

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 

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

Hi,

 

But below line is doing , i want to understand..can you explain?

.replace(/\n/g, "")

Hi, sure. It removes leading newline characters from the string.

Hope it helps