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
bharath kumar 52bharath kumar 52 

Problem with VF page in communities "Error occurred while loading a Visualforce page"

Hi All,

I am working on a module which requires me to send an attachment of the invoice as a pdf once i click a button and below is the code for your reference. The problem here is that the same code works flawlessly on the platform but it fails to work on communities with the following error "Error occurred while loading a Visualforce page" .Also, i am calling this method in another method that has void as its return type.
Would be glad if someone can help me on this.
public pagereference SendEmail(){
    // Define the email
    System.debug('inside SendEmail method:'+Inv.invoice_status__c);
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    PageReference pdf = Page.InvoicePagePDF;
   
    pdf.setRedirect(true); 
      Invoice__c InvoicemailVar = [ Some Query ];
      String emal = InvoicemailVar.Email ;
      system.debug('mail id of contact ' +emal );
     /*START Bharath Kumar - March 28,2016 - Skip this section */
    if (!Test.isRunningTest()){
    Blob b = pdf.getContent();
// Create the email attachment
    Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
    efa.setFileName('Invoice.pdf');
    efa.setBody(b);
    String addresses;
    email.setSubject( 'Invoice' );
    string[] test = new String[] {emal};
    email.setToAddresses( test  );
    email.setPlainTextBody(' Hi, your invoice has been generated' );
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
// Send it
    Messaging.SendEmailResult [] r =
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
       
 
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Invoice has been mailed.'));
            return null;
   }

 
Jessica Barillas 30Jessica Barillas 30
Hi! i have the same issue, did you know something about this?