You need to sign in to do that
Don't have an account?
Praveen Jha
Email notification when an attachment is added to a case-Urgent
How can case owner and case team get a notification when an attachment is added to a case??
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
trigger AttachmentTriggerDemo on Attachment (before insert) {
List<Account> accountList = new List<Account>();
Set<Id>accIds = new Set<Id>();
for(Attachment att : trigger.New){
//Check if added attachment is related to Account or not
if(att.ParentId.getSobjectType() == Account.SobjectType){
accIds.add(att.ParentId);
}
}
accountList = [select id, has_Attachment__c from Account where id in : accIds];
if(accountList!=null && accountList.size()>0){
for(Account acc : accountList){
acc.has_Attachment__c = true;
}
update accountList;
}
}
All Answers
Attachmetn Trigger example: http://www.sfdcpoint.com/salesforce/trigger-on-attachment-in-salesforce/
and check if the parent id is case if yes, then get case owner by querying case and send mail through SingleEmailMessage.
SingleEmailMessage example: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_forcecom_email_outbound.htm
Error: Compile Error: unexpected token: 'List' at line 2 column 4
trigger AttachmentTriggerDemo on Attachment (before insert) {
List accountList = new List();
Set accIds = new Set();
for(Attachment att : trigger.New){
//Check if added attachment is related to Account or not
if(att.ParentId.getSobjectType() == Account.SobjectType){
accIds.add(att.ParentId);
}
}
accountList = [select id, has_Attachment__c from Account where id in : accIds];
if(accountList!=null && accountList.size()>0){
for(Account acc : accountList){
acc.has_Attachment__c = true;
}
update accountList;
}
}
trigger AttachmentTriggerDemo on Attachment (before insert) {
List<Account> accountList = new List<Account>();
Set<Id>accIds = new Set<Id>();
for(Attachment att : trigger.New){
//Check if added attachment is related to Account or not
if(att.ParentId.getSobjectType() == Account.SobjectType){
accIds.add(att.ParentId);
}
}
accountList = [select id, has_Attachment__c from Account where id in : accIds];
if(accountList!=null && accountList.size()>0){
for(Account acc : accountList){
acc.has_Attachment__c = true;
}
update accountList;
}
}