How can I get the last comment in my email notification

Alon Grod
Tera Expert

Hi,

I have an email notification that should send an email to assigned to whenever a new additional comment is inserted.

How can I get only the last comment + how can I get only the comment without date, the sender, etc.

 

This is what I have in my email notification (a string + a dynamic field)

 

Screen Shot 2023-02-08 at 12.37.28.png

 

This is what Im getting in my Preview:

Screen Shot 2023-02-08 at 12.38.57.png

1 ACCEPTED SOLUTION

Basheer
Mega Sage

Hi @Alon Grod 

Use below in your email script

var comment = current.comments.getJournalEntry(1).split('\n')[1];
template.print(comment);
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

3 REPLIES 3

Rabarber
Tera Expert

Hi Alon,


We implemented the following email script:

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

          // Add your code here
	//template.print('Worknotes'+current.work_notes.getJournalEntry(1));
	template.print(current.comments.getJournalEntry(1).match(/\n.*/gm).join('').replace(/^\s*\n/gm, ""));

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

Basheer
Mega Sage

Hi @Alon Grod 

Use below in your email script

var comment = current.comments.getJournalEntry(1).split('\n')[1];
template.print(comment);
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Yaraslau
Tera Guru

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