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

To remove unwanted lines use trim() function of javascript

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

Thanks

Hit Like/Helpful/Correct if applicable

Manisha Kumari
Giga Expert

HI,

 

Try this one

var comments = current.comments.getJournalEntry(1);

var split_comments = comments.split(')')[1];

SomaSekharSane
Tera Expert

 

// This is to get latest worknote without time stamp

var Worknote = current.work_notes.getJournalEntry(1).split("(Work notes)\n"); // Replace work_notes with comments & (Work notes)\n with (Additional comments) to fetch latestComment

var latestWorknote = Worknote[1];

SOMASEKHARSAN_1-1695822766070.png

 

SOMASEKHARSAN_0-1695822737849.png