It's all about the answers!

Ask a question

How to get the list of the newly added comments

Surender Biyyala (403548) | asked Oct 09 '14, 2:45 p.m.
 Hi All,

I want to write a new email template that should collect all the newly comments that are entered.

#foreach($comment in ${workItem.comments.mostRecentFirst.takeFirst(1)})

This will give only one latest comment.

when the user enters a comment and also adds a new attachment. then the email is having only the comment but not the information regarding the attachment.

is there any way that I can achieve this?

Thanks in Advance.

One answer

permanent link
Donald Nong (14.5k414) | answered Oct 09 '14, 9:06 p.m.
Your code only retrieve one comment and that is exactly what you've got - takeFirst(1). Change the number to the count of comments that you would like to put into the email template. The sample code in the below document retrieves 5 most recent comments.

Surender Biyyala commented Oct 10 '14, 2:43 a.m.

Thanks Donald Nong.

My requirement is little different. I want only the new comments added by the user before saving the workitem. That means if user adds a comment and also an attachment then in this case the newly added comments were two.

if there are two attachments and one comment and user saved all at once then the newly added comments should be 3.

is there any way that i can achieve this?


Donald Nong commented Oct 12 '14, 8:12 p.m.

I'm a bit confused - it seems that you want to control the way how the comments are generated to suit your code. If you only want one, and only one comment in the email template, I'm not sure how you can reliably get the most recent "human written" one. What if a user just add an attachment without writing any words?
Just for your reference, the email notification in one of our RTC applications shows the last five comments.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.