• Sue Irvine
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi all, I have a process builder process that when a Case is created with certain criteria, a follow-up email is sent 3 days later if the Case still meets certain criteria. Following other suggestions on the forum I thought I had it appropriately bulkified by adding all the emails to a list and sending them all at once. However I'm still getting the "too many email invocations: 11" error when more than 10 follow-up emails are sent.Is this something unique to invoking the class via process builder, or am I missing something in my code?. Thanks!
 
Global class caseFollowupEmail {
 @InvocableMethod
public static void sendEmail(List<ID> ids) {
    List<Messaging.SingleEmailMessage> lstMails = new List<Messaging.SingleEmailMessage>();
    For (ID i: ids){       

        Case c = [select id,Send_Followup__c, Reason, FollowUp__c, Origin,ContactId  from Case where id=:i LIMIT 1];     
        string[] advList = getAdvisorList(c.contactid);
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setTargetObjectId(c.ContactId);

        List<EmailTemplate> em = new List<Emailtemplate>();
        
        //the list of ilness-related Cases that get a follow-up email
        Set<String> illnessList = new Set<String>{'Illness','Concussion','Mononucleosis'};

        //select the appropriate template based on the type of Case   
        If (c.Origin=='SIT'){
        	em = [select id from emailtemplate where isActive=true and name='SIT: FollowUp' limit 1];
        }
        else if(illnessList.contains(c.Reason))
        {
        	em = [select id from emailtemplate where isActive=true and name='Case Illness FollowUp' limit 1];
              if (!advList.isEmpty()){
            	mail.setccAddresses(advList);
        	  }
        }
        
        //send_followup__c is a checkbox on the Case layout where staff indicate whether or not to send a follow-up email
        //only send email if we have a template, and send_followup is checked
        If (em.size()>0 && c.Send_Followup__c==true){
        	OrgWideEmailAddress org = [select id from OrgWideEmailAddress where DisplayName='Student Services'];
	        mail.setTemplateId(em[0].id);
	        mail.setWhatId(c.id);   
	        mail.setBccSender(false);
	        mail.setUseSignature(false);
	        mail.setReplyTo('studentservices@school.edu');
	        mail.setOrgWideEmailAddressID(org.id);
	        mail.setSaveAsActivity(true);    
           //add email to list
		    lstMails.add(mail);
       		}
        }
	//outside the for loop, send all the messages
    last_sendEmail_result = Messaging.sendEmail(lstMails);
    }
    
    public static Messaging.SendEmailResult[] last_sendEmail_result {get; private set;}



 
I'm trying to complete the "Testing Apex Triggers" challenge. My Test class is working and has 100% code covereage but Trailhead keeps telling me "No Apex test class named 'TestRestrictContactByName' was found". There is no namespace in my de org. I'd appreciate any help in completing this challenge - it looks like it should be working. Thanks!
 
@isTest
public class TestRestrictContactByName {
    @isTest static void TestRestrictContact() {
             
        Contact con2 = New Contact(lastname='INVALIDNAME', firstname='tom');
        
        Test.startTest();
        Database.saveresult result = Database.insert(con2, false);
        Test.stopTest();

        System.assert(!result.isSuccess());
        System.assert(result.getErrors().size() > 0);
        System.assertEquals('The Last Name "'+con2.lastname+'" is not allowed for DML',
                             result.getErrors()[0].getMessage());
    }
    @isTest static void TestValidContact(){
        Contact con = new Contact(lastname='jones',firstname='tom');

        Test.startTest();
        Database.saveresult result2 = Database.insert(con,false);
        Test.stopTest();
        System.assert(result2.isSuccess());
        System.assert(result2.getErrors().size() <1);
    
}    
}



 
Hi all, I have a process builder process that when a Case is created with certain criteria, a follow-up email is sent 3 days later if the Case still meets certain criteria. Following other suggestions on the forum I thought I had it appropriately bulkified by adding all the emails to a list and sending them all at once. However I'm still getting the "too many email invocations: 11" error when more than 10 follow-up emails are sent.Is this something unique to invoking the class via process builder, or am I missing something in my code?. Thanks!
 
Global class caseFollowupEmail {
 @InvocableMethod
public static void sendEmail(List<ID> ids) {
    List<Messaging.SingleEmailMessage> lstMails = new List<Messaging.SingleEmailMessage>();
    For (ID i: ids){       

        Case c = [select id,Send_Followup__c, Reason, FollowUp__c, Origin,ContactId  from Case where id=:i LIMIT 1];     
        string[] advList = getAdvisorList(c.contactid);
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setTargetObjectId(c.ContactId);

        List<EmailTemplate> em = new List<Emailtemplate>();
        
        //the list of ilness-related Cases that get a follow-up email
        Set<String> illnessList = new Set<String>{'Illness','Concussion','Mononucleosis'};

        //select the appropriate template based on the type of Case   
        If (c.Origin=='SIT'){
        	em = [select id from emailtemplate where isActive=true and name='SIT: FollowUp' limit 1];
        }
        else if(illnessList.contains(c.Reason))
        {
        	em = [select id from emailtemplate where isActive=true and name='Case Illness FollowUp' limit 1];
              if (!advList.isEmpty()){
            	mail.setccAddresses(advList);
        	  }
        }
        
        //send_followup__c is a checkbox on the Case layout where staff indicate whether or not to send a follow-up email
        //only send email if we have a template, and send_followup is checked
        If (em.size()>0 && c.Send_Followup__c==true){
        	OrgWideEmailAddress org = [select id from OrgWideEmailAddress where DisplayName='Student Services'];
	        mail.setTemplateId(em[0].id);
	        mail.setWhatId(c.id);   
	        mail.setBccSender(false);
	        mail.setUseSignature(false);
	        mail.setReplyTo('studentservices@school.edu');
	        mail.setOrgWideEmailAddressID(org.id);
	        mail.setSaveAsActivity(true);    
           //add email to list
		    lstMails.add(mail);
       		}
        }
	//outside the for loop, send all the messages
    last_sendEmail_result = Messaging.sendEmail(lstMails);
    }
    
    public static Messaging.SendEmailResult[] last_sendEmail_result {get; private set;}



 
Hello, appologies if this has already been discussed, couldn't find an answer.  I understand that is is expected that with Spring 15, displaying dashboards in a visualforce page will no longer work using iframe.  What is the alternative?  I'm willing to go though and update all my custom visualforce pages, but just not sure what changes I have to make.  Here is a sample of what is no longer working:
<apex:pageBlock mode="maindetail">
   <iframe src="/01Z140000016xEN?isdtp=nv" height="1020px" width="305px" style="position:relative; top:-260px;" frameborder="false"/>
</apex:pageBlock>

Thanks in advance!