• Taylor Ochs 5
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I need to write a trigger to nofity new members when they are added to an account team.  My code doesn't seem to work, any help or ideas?

trigger Notify_Account_Team on Account (before insert, before update) {
    for(Account acct : trigger.new){
        List<Messaging.SingleEmailMessage> atm = new List<Messaging.SingleEmailMessage>(); 
        EmailTemplate et=[Select id from EmailTemplate where
                          DeveloperName=:'Notify_Assign'];
            List<AccountTeamMember> recips = new List<AccountTeamMember>(
[SELECT UserId
FROM AccountTeamMember
for(AccountTeamMember rid : recips){
mail.setTargetObjectId(rid.UserId);
mail.setSenderDisplayName('Salesforce System');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
mail.setTemplateId(et.Id);
        }

    }
atm.add(mail);

}
I need to write a trigger to nofity new members when they are added to an account team.  My code doesn't seem to work, any help or ideas?

trigger Notify_Account_Team on Account (before insert, before update) {
    for(Account acct : trigger.new){
        List<Messaging.SingleEmailMessage> atm = new List<Messaging.SingleEmailMessage>(); 
        EmailTemplate et=[Select id from EmailTemplate where
                          DeveloperName=:'Notify_Assign'];
            List<AccountTeamMember> recips = new List<AccountTeamMember>(
[SELECT UserId
FROM AccountTeamMember
for(AccountTeamMember rid : recips){
mail.setTargetObjectId(rid.UserId);
mail.setSenderDisplayName('Salesforce System');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
mail.setTemplateId(et.Id);
        }

    }
atm.add(mail);

}