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 get latest comment from Comments and request comment fields

Hareesha
Tera Contributor

I have a requirement to get latest comment from comments and request comment in email script

Hareesha_0-1683735359702.png

 

4 REPLIES 4

Manmohan K
Tera Sage

Hi @Hareesha ,

 

You can use below lines in mail script to get latest comment and request comment

 

var workNote = current.work_notes.getJournalEntry(1);    

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

 

Hi @Manmohan K 

 

My requirement is i need either the worknote or request comment which is last updated . Is it possible?

Karan Chhabra6
Mega Sage

Hi @Hareesha,

 

Please use the following email script to fetch the latest comments

(function runMailScript(current, template, email, email_action, event) {

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

template.print(comment);

})(current, template, email, email_action, event);

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

Hi @Karan Chhabra6 

 

My requirement is i need either the work note or request comment which is last updated . Is it possible?