Skip to main content
Prachi Choudhary (Self) 님이 #Trailhead Challenges에 질문했습니다

Hi,

I am currently facing an issue in our production environment related to the generation of a Proforma Invoice and saving the corresponding PDF to the 'Notes and Attachments' section.

In our Order object, when the stage is set to 'Invoice,' we trigger the generation of a Proforma Invoice by clicking the 'Generate Invoice' button. The PDF rendering is handled through an Aura component named 'generateOrderContract,' which embeds a Visualforce page called 'ProformaInvoiceNew.'

While this functionality works seamlessly in our sandbox environment, post-deployment to production, an error occurs when attempting to save the rendered PDF to attachments. The error displayed on the UI is as follows: "Error: An internal server error has occurred. Error ID: 189341393."

The code is:

 

            PageReference pdfPage = new PageReference(pageurl);

            Blob pdfData;

            if (!Test.isRunningTest()) {pdfData = pdfPage.getContentAsPDF();}

            else {

                pdfData = Blob.valueOf('This is a test.');

            }

In this getContentAsPDF(); is not working(not getting any value).   

Please help me with some solution. 

답변 1개
  1. 9월 16일 오후 8:44

    Hi Prachi,

    Since getContentAsPDF() is working in the sandbox but failing in production, I would first compare the Visualforce page and user/configuration between the two environments. 

     

    Please check:

    • The ProformaInvoiceNew Visualforce page is deployed and accessible in production.
    • The running user has the required access to the Visualforce page, Apex class, and objects/fields referenced by the page.
    • Any custom settings, custom metadata, permissions, or referenced records used by ProformaInvoiceNew are available in production.
    • Check whether the pageurl being passed to PageReference is valid in production.
    • Review the debug log for the user executing getContentAsPDF() to see whether the Visualforce page is throwing an exception while being rendered.

    You can also test the Visualforce page directly in production using the same user to determine whether the issue is with the page rendering or with the attachment creation. 

     

    Since Salesforce is returning an Internal Server Error with an Error ID, if the page works directly and all permissions/configuration are correct but getContentAsPDF() still fails, I would recommend creating a Salesforce Support case and providing the Error ID (189341393) and the debug logs so Salesforce can investigate the server-side error.

0/9000