You need to sign in to do that
Don't have an account?
Use Parent User Id in Trigger
I'm trying to create a trigger to send an email notification to the original creator of a case anytime a Case Comment is added. I've tried everything and I can not get the syntax correct. Can anyone offer any suggestions. I keep getting an error with the query statement stating unexpected token 'cc'
The code I have is:
trigger NotifyCaseCreator on CaseComment (after delete, after insert, after undelete,after update) {
for(CaseComment cc:[select parent.createdby.email from cc where id = cc record id]){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {cc};
}
mail.setToAddresses(toAddresses);
mail.setSubject('A New Case Comment Has Been Added');
string msg = 'A Comment has been added to a Case that you had created. The Comment was added by UserID:';
for (CaseComment u : Trigger.new) {
msg = msg + u.CreatedBy;
}
mail.setHtmlBody(msg);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
Maybe something like:
I didn't dive into your logic at all, just fixed some errors in how you are calling things. Are you creating this in Eclipse?
If not, I would recommend it, as it points out some obvious errors and also offers some suggestions.