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
Nazneen ArabNazneen Arab 

notes and attachments

Hi Everyone,

I have a visualforce page which has notes and Attachments related list on it. 
There is a button on the page which when clicked should download a pdf and attach it in the Notes and Attachments related list.

When I click on View link on the related list (image1), I get the error(Image2).

Code called on the command button is:
 public PageReference downloadPDF(){
        System.debug(' Inside downloadPDF1 ');
      PageReference pdf =  Page.EventsBudgetPDFVFP_New;
      pdf.getParameters().put('id',(String)eventBudget.id);
      pdf.setRedirect(true); 
        
      Blob b = null;
     if (Test.IsRunningTest())
        {
            b=Blob.valueOf('UNIT.TEST');
        }
        else
        { 
            b = pdf.getContent();
        }
        Attachment att = new Attachment();
        att.body = b;
        att.Name = eventBudget.Name +' - '+ '.pdf';
        att.ParentId = eventBudget.Id;
        insert att; 
     return new PageReference('/apex/ViewEventsBudget?id='+eventBudget.id);   
     }

Is there any thing that I am missing?
The same is working for other pages but not for this.

Thanks,
NazneenNotes and AttachmnetsError