You need to sign in to do that
Don't have an account?

How to call future method from After insert trigger
hello ,
I am trying to call a future method from after insert but getting some error, below is the code piece
calling this method from after inset trigger like ;-
if(Trigger.isAfter && Trigger.isInsert){
THA_Case_Trigger_Cx.updateEmailTemplateId(Trigger.NEW);
}
Error is -
Method does not exist or incorrect signature: void updateEmailTemplateId(List<Case>) from the type THA_Case_Trigger_Cx at line 65 column 25.
Can anyone please help me out to know why I am getting this error and how to solve it .
I am trying to call a future method from after insert but getting some error, below is the code piece
@future public static void updateEmailTemplateId(List<ID> recordIds){ List<Case> cassesList = [SELECT id,THA_Case_Language__c,THA_Source__c, NPR_Member_Segment__c,Subject, Email_Template__c from case WHERE id IN :recordIds]; List<String> IdCase = new List<String>(); //for(Case caseIters :casesList){ // IdCase.add(caseIters.id); // } List<Case> lst = new List<Case>(); for(Case c :[select Id,Email_Template__c from case where Id IN :Trigger.New]){ String templateName = 'THA_Tmp_' + DateTime.now().getTime(); System.debug('templateName=' + templateName); c.Email_Template__c = 'hey bro'; lst.add(c); { update lst; } } }
calling this method from after inset trigger like ;-
if(Trigger.isAfter && Trigger.isInsert){
THA_Case_Trigger_Cx.updateEmailTemplateId(Trigger.NEW);
}
Error is -
Method does not exist or incorrect signature: void updateEmailTemplateId(List<Case>) from the type THA_Case_Trigger_Cx at line 65 column 25.
Can anyone please help me out to know why I am getting this error and how to solve it .
As per the documentation, Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. Methods with the future annotation cannot take sObjects or objects as arguments.
You'll have to pass a List<Id> rather than a List<Case>
If you find this information helpful, please mark this answer as Best. It may help others in the community