• Jessica Barillas 30
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
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;
      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();
    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;


I created a VF Page so the view for a custom object would show the related list as tabs. The page works great within the full app, but it gives the error "Error occurred while loading a Visualforce page" when any customer portal(coummunity) users tries to view a record in the object.  I turned on debug, but it does not give me any details on the error. 


The portal user profile does have the VF page assigned to it. 


Below is the code for the page and below that is the debug log. 


Any help would be much appreciated.  



<apex:page standardController="LCM_Services__c" showHeader="true" >
<apex:messages />
    <apex:tabPanel switchType="client"  selectedTab="name" id="theTabPanel">
        <apex:tab label="Project" name="LCM_Services__c" id="tabdetails">
            <apex:detail relatedList="false" title="true"/>
        <apex:tab label="Related Assets" name="LCM_Asset__c" id="tablcmassets">
            <apex:relatedList list="LCMAssets__r"/> 
         <apex:tab label="Trip Reports" name="Trip_Report__c" id="tabtripreports">
            <apex:relatedList list="Trip_Reports__r"/> 
        <apex:tab label="Battery Management" name="Battery_Management__c" id="tabbatterymgmt">
            <apex:relatedList list="Battery_Management__r"/> 
        <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt">
            <apex:relatedList list="NotesAndAttachments" /> 
        <apex:tab label="Activity History" name="ActivityHistory" id="tabActHistory">
            <apex:relatedList list="ActivityHistories" /> 
        <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
            <apex:relatedList list="OpenActivities" /> 


09:38:10.052 (52510000)|EXECUTION_STARTED
09:38:10.052 (52554000)|CODE_UNIT_STARTED|[EXTERNAL]|066a00000016pcz|VF: /apex/tabbedProject
09:38:10.895 (158993000)|CUMULATIVE_LIMIT_USAGE
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of code statements: 0 out of 200000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10


09:38:10.159 (159045000)|CODE_UNIT_FINISHED|VF: /apex/tabbedProject
09:38:10.159 (159056000)|EXECUTION_FINISHED
  • October 25, 2013
  • Like
  • 0