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

Class not displaying record values and attachment
Hi Friends,
I need help in getting record values from lead object for below class.
I am getting blank values when testing.
Thanks in advance.
I need help in getting record values from lead object for below class.
I am getting blank values when testing.
Class :: public with sharing class helperleadTrigger { public static List<Lead> sendEmail(List<Lead> leads){ Leads = [SELECT Id, Name, FirstName, LastName, Email, Business_Hub__c, Title__c FROM Lead WHERE Id =: recordId]; for(Lead l : leads){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[]{'test@gmail.com'}; mail.setToAddresses(toAddresses); mail.setTargetObjectId(l.Id); mail.setTemplateId('00X5D000000EmxQ'); mail.saveAsActivity = false; Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); //Set email file attachments List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>(); for (Attachment a : [select Id, Name, Body, ContentType, BodyLength from Attachment where ParentId =: l.Id]) { // Add to attachment file list Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment(); efa.setFileName(a.Name); efa.setBody(a.Body); efa.setContentType(a.ContentType); fileAttachments.add(efa); } mail.setFileAttachments(fileAttachments); } return leads; }
Thanks in advance.
Can you check WHERE clause in line 6. I don't see any variable "recordId" in your class but directly used in query. Please do check your code and update it.
Raji M
Thanks for reply. Sorry for typo.
WHERE Id =:ApexPages.currentPage().getParameters().get('id')
Could you please check my code now and let me know why my WFR is not populating the data.
Thanks.