You need to sign in to do that
Don't have an account?
Contract Attachment Trigger Mysteriously Stopped Working
We wrote a trigger to email select individuals when an attachment is added to a contract record (see http://boards.developerforce.com/t5/Apex-Code-Development/How-to-Satisfy-quot-test-coverage-quot-for-a-Trigger/m-p/494099/highlight/true#M91277 for the original thread/code).
This worked fine for a while, but now when we add an attachment, mysteriously no system email is being sent. Nothin in the debug logs to suggest a problem, and the trigger is still active.
Any ideas?
Here's the trigger code:
trigger Send_Email on Attachment (after insert) {
List<Id> contractIds=new List<Id>();
for (Attachment att : trigger.new)
{
contractIds.add(att.parentId);
}
Map<Id, Contract> contracts=new Map<Id, Contract>();
contracts.putAll([select id, Name, contract.ContractNumber from Contract where id IN :contractIds]);
Attachment attach = trigger.new[0];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'xxx@xxx.org'};
String[] bccAddresses = new String[] {'xxx@xxx.com'};
mail.setToAddresses(toAddresses);
mail.setbccAddresses(bccAddresses);
mail.setReplyTo('donotreply@xxx.org');
mail.setSenderDisplayName('Salesforce Support');
Contract contract=contracts.get(attach.parentId);
if (null!=contract)
{
mail.setSubject('Attachment Added on : ' + contract.name + ' for ' + contract.ContractNumber);
mail.setHTMLBody('An attachment has been added to the above Contract record. Please visit Salesforce for details: https://na5.salesforce.com/' + contract.id);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
Try looking at the Email Log files under monitoring to see when the last email was delivered. This should be your first place.
Hi Kartik,
Thanks for the reply!
Looks like one needs to actually request an email log file to receive it, and the max request time is 7 days. Problem is, I don't know when exactly the emails stopped so not sure which log time period would be enlightening. I took my best guess though, and am awaiting the results.
Any other ideas??
Received the email log, but not really sure what I'm looking for here - I see entries in the log that might have been previously successful instances of the Contract Attachment email trigger, but no error information.
Nothing seems to indicate why the emails would have stopped.
Any ideas?