Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Pranav Bhagat
Kilo Sage

try this

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

Hi,

by adding match(/\n.*/gm).join("\n") this is giving extra new lines as shown in image. how can we remove this linesfind_real_file.png

Thanks & Regards,

Nikita

try removing \n

 

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

 

Hi,

It is not working as expected

 

Thanks,

Nikita