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
Rahul AlladaRahul Allada 

Error: Too many nested getContent calls

I am trying to attach my Vf page which is rendered as pdf to the Files section. But the error " Too many nested getContent calls." is being thrown.

The code is as follows:
<apex:page action="{!attachOfferPDF}"
       standardController="Quote__c"
       extensions="QuotePDFController"
       readOnly="true"      
       applyHtmlTag="false"     
       sidebar="false"     
       showHeader="false"     
       cache="true"     
       renderAs="pdf">

Apex Controller:
public with sharing class QuotePDFController {
public PageReference rtn;
public static string recursion = 'false' ;
public string parId;
public quote__c quotesRecords {get;set;}
public Quote_header__mdt quotesHeaders {get;set;}

public QuotePDFController(ApexPages.StandardController standardController){
    quotesRecords = new Quote__c();
    parId = standardController.getId();
        system.debug('parid '+parId);
    quotesRecords = [select Id,Name, (SELECT Id,    Product_Name__c,DifficultyLevel__c,Product__r.Name,Level_Course__c,Onetime_Fee__c,OS__c,Vlab_Configuration__c,PerHourCost__c,PerChallengeEvaluationFee__c FROM Quote_Line_Items__r) FROM Quote__c where Id = 'a071y0000015mwEAAQ' limit 1];
    
    
}
public void attachOfferPDF() {
    
    
    if ( recursion == 'false'){
        recursion = 'true';
        system.debug(recursion);
        PageReference pdfPage = Page.QuoteGeneration;
        Blob pdfBlob = pdfPage.getContentAsPDF();
        Attachment a = new Attachment(parentId = 'a071y0000015mwEAAQ', name='Rahul' + '.pdf', body = pdfBlob);
        insert a;
        system.debug('id is '+a.id);
    }}
}

Not able to figure why this error is being thrown.
AbhishekAbhishek (Salesforce Developers) 
Rahul,

Try the suggestions as mentioned in the below developer discussion,

https://salesforce.stackexchange.com/questions/83275/too-many-nested-getcontent-calls


For further reference check this,
https://developer.salesforce.com/forums/?id=906F000000097DbIAI


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.