function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JaiJai 

Please help me on the below error

trigger
----------
trigger OpportunityUpdateFromTicket on Case (before insert,after insert,before update,after update) {
   
    if(trigger.isAfter&&(trigger.isInsert || trigger.isUpdate))
    {
    OpportunityUpdateFromTicketHandler.emailNotificationFromIteroBackOffice(trigger.new,trigger.oldMap);
   
    }
   }

Helper class
------------------------
public class OpportunityUpdateFromTicketHandler {
    
    Public static void emailNotificationFromIteroBackOffice(List<case> ticketList,Map<String,Case> oldMapCase)
    {
        EmailTemplate et = [SELECT Id,Subject, Body FROM EmailTemplate WHERE DeveloperName ='iTero_back_office_Template'];
       Map<ID, RecordType> recordTypeMap = New Map<ID, RecordType>([Select ID, Name From RecordType Where sObjectType = 'Case']);
        List<string> toAddress = new List<string>();
        toAddress.add('scannerinstall@aligntech.com');
        List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
        
        for(Case ticket :ticketList)
        {
        if(recordTypeMap.get(ticket.recordTypeID).name.containsIgnoreCase('iTero Contracts') && ticket.Ticket_Type__c =='New scanner sale' && ticket.Final_Status__c != oldMapCase.get(ticket.Id).Final_Status__c && ticket.Final_Status__c =='Processed/Assigned to Logistics' )
        {
            if(ticket.Region__c =='NA' || ticket.Region__c =='LATAM')
            {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(et.Id);
                mail.setToAddresses(toAddress);
                mail.setSubject(et.subject);
                mail.setHTMLBody(et.Body);
                allmsg.add(mail);
            }
        }
        
        }
        Messaging.sendEmail(allmsg);
        
   }

}

error:
----------
Method does not exist or incorrect signature: void emailNotificationFromIteroBackOffice(List<Case>, Map<Id,Case>) from the type OpportunityUpdateFromTicketHandler

Thanks!!
Best Answer chosen by Jai
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

There is small error in the Method definition.

Can you please change the input parameters of the method as below.
 
Public static void emailNotificationFromIteroBackOffice(List<case> ticketList,Map<Id,Case> oldMapCase)

Always Trigger.oldmap witll give map<id,Sobject> .

As you gave Map<String,Sobject> it thrown error.

Let me know if you face any error.

If this solution helps, Please mark it as best answer.

Thanks,

 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

There is small error in the Method definition.

Can you please change the input parameters of the method as below.
 
Public static void emailNotificationFromIteroBackOffice(List<case> ticketList,Map<Id,Case> oldMapCase)

Always Trigger.oldmap witll give map<id,Sobject> .

As you gave Map<String,Sobject> it thrown error.

Let me know if you face any error.

If this solution helps, Please mark it as best answer.

Thanks,

 
This was selected as the best answer
Aarti ShekhawatAarti Shekhawat
you have defined the wrong Map<String, Case> instead of Map<Id, case>
Use this :
    Public static void emailNotificationFromIteroBackOffice(List<case> ticketList,Map<Id,Case> oldMapCase) 
 
JaiJai
Hi Sai Praveen,

Thanks for your help it is working know!