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
liron169liron169 

Internal SF error when in function getContentasPDF

Hi,

I have report - PDF page - that run sometimes on large amount of data.
with too much data, it failed when loading the page to the screen, so I try different approach- generating the page in background, and attach it to the chatter.
It does incrase the capacity of the report, but still in some amount of data it fails, and I can see in log Internal Salesforce.com Error.
I'm not hitting any other SF limitation (CPU close to limit, but not beyond).

The PDF (that failed) expected to be ~1.5MB, with ~800-1000 pages.
I able to generate it with ~1MB, ~600 pages.

Anyone have idea possible reason for this error?




global class AddPdfToRecord{
    webservice static void addPDF(){ 
     
       PageReference pdf = Page.TestLiron;
      
       pdf.getParameters().put('parm1','111');
       pdf.getParameters().put('parm2','222');
 
       pdf.setRedirect(true);
      
      //system.debug('URL: ' + pdf.getURL());

       Attachment attach = new Attachment();
       Blob body;
       try
       {
           body = pdf.getContentasPDF();        //here the failure

            // post to chatter
            FeedItem post = new FeedItem();
            post.ParentId = '0F9c00000008efE'; // nickforce chatter group id
            post.Body = 'Report for..';
            post.Type = 'ContentPost';
            post.ContentData = body;
            post.ContentFileName = 'FMR_TEST' + '.pdf';

            insert post;
       }
       catch(Exception e)
       {system.debug('EEEEEEEEEEEEEEEE'  + e) ;}
   }
}
Sonam_SFDCSonam_SFDC
does the log give you any number say in this format XXXXXXX (-XXXXXX )  together with the internal server error - can you please share the log on this thread so as to check this further..
liron169liron169
Hi,
No number is given.
Only error indication
User-added image
liron169liron169
Just to update - I found that this is limitation exception. - 1 of the limits reached, although it run asynchrony.

We don't see error number as it is not a bug in SF, and we don't see exception error is this exception cannot be cauot.
Arvind_SinghArvind_Singh
Hello All, 
In case anyone facing this issue, Check the access for VF page that you coverting to PDF. I was getting same error tried all way but finally was able to make it work after Enale the Access for VF page for Profile. 

Profile - VisualForce Page (EDIT) > Add VF page - It will solve this issue.