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

Sumanth16
Kilo Patron

Hi @Shwetha Shenoy ,

 

Please modify syntax below like this:

var comment = current.comments.getJournalEntry(1).split('\n')[1];
template.print(comment);

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Many Thanks @Sumanth16 

But this doesn't work as expected.

HI @Shwetha Shenoy ,

 

Can you share the script that you are trying?

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Hi @Sumanth16 ,

 

This doesn't work as expected,

For instance when we write the comments in this manner - 

 

Rejected this change request 

Check with you peers.

 

The end result is not as expected

ShwethaShenoy_0-1709195028473.png