• Amit Kumar 87
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

 

I have a VFP within which I have written:

Visualforce page Name: MyAttach:

<apex:page standardController="CustomObj__C" extension="MyClass" action="saveAttach">

//here I generate PDF data with the help of both standard controller and its extension

</apex:page>

 

in MyClass I have written this method as:

 

public void saveAttach()

{

    System.debug('Inside saveAttach');
    PageReference pdfPage = Page.MyAttach;
    pdfPage.getParameters().put('id',q.id);//q is variable of CustomObj__c which fetches records.
    Blob pdfBlob ;//= pdfPage.getContent();
    pdfBlob = pdfPage.getContent();
    Attachment a = new Attachment(parentId = q.id, name=q.id + '.pdf', body = pdfBlob);
    insert a;
    pdfBlob = Blob.valueOf('Unit Test Attachment Body');?

}

 

When I click a custom button(having MyAttach VFP) from CustomObj__c page layout, it give me error Too many nested getContent calls, I don't know why is this going in infinite loop.

Any Ideas/thoughts/workarounds to this are highly appreciated.

Thank you!

:

Regards,

Lakshman