We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get the last comment added by the agent onto notification

Shwetha Shenoy
Tera Expert

I have a use case where I am told to get the last comment added by an agent when rejecting the change request

I tried to use the below method using an email script but it doesn't fit my exact requirements -

 

(function runMailScript(current, template, email, email_action, event) {
var latestComment = current. comments.getJournalEntry(1);
template.print(latest comment);
})(current, template, email, email_action, event);
 
The output I get is the last comment as well as the additional details such as time and the user's name, which shouldn't be the case.
 

Something like this - 

28/02/2024 19:53:39 GMT - Shwetha Shenoy (Comments) reject and cancel

 

I only require the comments i.e. in the above scenario - reject and cancel and not the extra details i.e - 28/02/2024 19:53:39 GMT - Shwetha Shenoy.

 

6 REPLIES 6

Hi @Shwetha Shenoy 

 

Below post could be helpful :

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0529930

 

Thanks & Regards

Amit Verma

Thanks and Regards
Amit Verma

Yaraslau
Tera Guru

Try ${comments:1} or ${comments:2} or ...