Including Case Comments in Case Assignment Email
Including case comments in the case assignment email allows the recipient to see exactly what is going on before even logging in to Salesforce.
You need a visualforce email template for this. You can use an apex:repeat component in your email template, but there is no sort order on those. Really, as best as I can find, its just random.
So I went ahead and created a custom component to select comments and sort. Now i can include just the last 3 comments to keep it simple, and its sorted by date, with most recent first.
Credit: This StackExchange post was hugely helpful in making this happen
I altered the solution a bit to use an apex:repeat in a table in the custom component, instead of a datalist, as i found the formatting better. The code for controller, component, test class, and vf email template is all copied below for your pleasure.
Continue reading →