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

Hello, I have created a flow ,visualforce page ,email template ,email alert for generating pdf but i want what pdf is generating it will also save in notes and attachment of particular account here I'm not getting how to save the pdf in notes & attachment

PriyaPriya (Salesforce Developers) 
Hi Jaishri,

Try this 
public void attach() {

Attachment myAttach = new Attachment();

myAttach.ParentId = 'xxxxxxxxxx';//Id of the object to which the page is attached = 'DisplayName.pdf';

PageReference myPdf = Page.myPdfPage;//myPdfPage is the name of your pdf page

myAttach.body = myPdf.getContentAsPdf();

insert myAttach;

Reference Link (

Kindly mark it as the best answer if it works for you.


Thanks & Regards,

Priya Ranjan