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

Future class in a trigger
Hi All,
I have a trigger and a batch class. the class is
The triger is
When i was deploying it to prod I got a error like this "
This Apex class has batch or future jobs pending or in progress". I checked the checkbox in deployment settings option. But after deployment mail is not delivered to users. Do I need to schedule my jobs again?
Thanks,
Anuj
I have a trigger and a batch class. the class is
global class AsyncApexClass{ @future public static void sendEmail(Set<Id> sendList){ List <Notes__c> notesList = new List<Notes__c>(); notesList.clear(); for(List<EmailMessage> emailmsglist:[select Id,parentId,Parent.Email__c,Parent.Contact.Email,ToAddress, FromAddress, Subject, TextBody, HTMLBody, CreatedDate from EmailMessage where id in :sendList] ) { for(EmailMessage emlist :emailmsglist){ Notes__c note= new Notes__c(); // Create a note object note.Case__c= emlist.parentid; IF (emlist.HTMLBody != NULL && emlist.HTMLBody != ''){ note.Message__c = emlist.HTMLBody; } else { note.Message__c = emlist.TextBody; } note.Sent_To__c = emlist.ToAddress; note.From__c = emlist.FromAddress; note.Subject__c = emlist.Subject; note.Datetime_Created__c = emlist.CreatedDate; if (emlist.Parent.Contact.Email == emlist.ToAddress || emlist.Parent.Email__c == emlist.ToAddress) // If the email is the same as Case's contact email or Email__c on Case itself, the type is a response. { note.Type__c = 'Response'; } else { note.Type__c = 'Forward/Others'; } notesList.add(note); // Add note object to the list } } // If the note list has records, insert the list. if(notesList.size()>0) { insert notesList; } } }
The triger is
trigger CreateNotes on EmailMessage(after insert) { //Variable declaration Set<Id> collectEmailSet = new Set<Id>(); for(EmailMessage msg : Trigger.New){ collectEmailSet.Add(msg.Id); } if(collectEmailSet.size()>0){ AsyncApexClass.sendEmail(collectEmailSet); } }
When i was deploying it to prod I got a error like this "
This Apex class has batch or future jobs pending or in progress". I checked the checkbox in deployment settings option. But after deployment mail is not delivered to users. Do I need to schedule my jobs again?
Thanks,
Anuj
Check in Apex Jobs to see whether the job is failing due to errors.
--
Magulan Duraipandian
www.infallibletechie.com
Please check in that this AsyncApexClass is Scheduled in Scheduled Jobs if yes then delete this schedule job and depoy it again. I hope it will work.
Thanks