How to remove time stamp and name from additional comments?

Nikita40
Tera Contributor

Hi All,

I have created an after insert/update business rule on problem table to copy additional comments from problem to incident, and used below script

var inc = new GlideRecord('incident');
inc.addQuery('sys_id', current.u_reference_1);// u_refernce_1 is name of incident field on problem form
inc.query();
while (inc.next()) {

 inc.comments = current.comments.getJournalEntry(1);
 inc.update();
}

find_real_file.png

please help me to remove the name and timestamp as shown in above image that is also getting copied and pasting in incident additional comments..

Thanks in advance!!!

1 ACCEPTED SOLUTION

Hi @Nikita 

I checked this in background script and its working

inc.comments = current.comments.getJournalEntry(1).match(/\n.*/gm).join('').replace(/^\s*\n/gm, "");

View solution in original post

12 REPLIES 12

Hi @Nikita 

I checked this in background script and its working

inc.comments = current.comments.getJournalEntry(1).match(/\n.*/gm).join('').replace(/^\s*\n/gm, "");

Hi Pranav,

Thank you for your response, Its working as expected and removing new lines.

Thanks again.....

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nikita,

refer solution from Deepak from below link

Remove User info and timestamp from commets

Regards
Ankur

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

Sumit Suthar
Mega Expert

Hi Nikita,

This work for me have a look

var inc = new GlideRecord('incident');
inc.addQuery('sys_id', current.s_id); 
inc.query();
while (inc.next()) {

inc.comments = current.comments.getJournalEntry(1).match(/\n.*/gm).join("\n");
inc.update();
}


find_real_file.png



Regards
Sumit

Hi,

By using the experession below expression, it is giving unwanted lines.I dont want the unwanted lines.

match(/\n.*/gm).join("\n");

Thanks,

Nikita