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
Polayya reddyPolayya reddy 

Error in apex class:attachmentPDF Error

Hi guys,
i am gettting an error showing that attachment pdf doesnot exit any solution for this. 

PageReference pdf = Page.attachmentPDF;
pdf.getParameters().put('id',(String)account.id); pdf.setRedirect(true);
// Take the PDF content Blob b = pdf.getContent();
// Create the email attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('attachment.pdf');
efa.setBody(b);

Thanks
Reddy
Lokesh__PareekLokesh__Pareek
Hi Polayya,

Please check "attachmentPDF" visualforce page that you are referring  must exist.

PageReference pdf = Page.existingPageName ;

Also you cannot typecast account.id to String as,
account.id - instance of Schema.SObjectField, 
and instance of Schema.SObjectField is never an instance of String rather use,

String.valueOf(account.id)

Hope it helps!





 
Lalit Karamchandani 27Lalit Karamchandani 27
Hi Polayya,
First tell me your senerio so i will tell you properly