• mark_ellul
  • 0 Points
  • Member since 2010

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

Hi All,

I built a VF page with custom controller which calls another VF page that returns a PDF. The PDF is is extracted via getContent(), and attached to an email. It all works fine in the sandbox through the UI, but the test method fails, unfortunately without detailed log information.


I already found these two threads but none really points to an explanation why it fails in test methods while working fine in the UI:





Here is the relevant code from the action method:


    public PageReference send(){

        for (string address:CCAddresses)
        	if(!address.endsWith('@symmetricom.com')) address += '.full';
        PageReference pdfPage = Page.quotePDF;
        System.Debug('pdfPage::::::::::::::::::::::::::::::::::::::: ' + pdfPage);
        transient Blob theBlob;
        theBlob = pdfPage.getContent();
        transient Attachment a = new Attachment (
            parentID = theQuote.ID,
            name = 'SymmQuote ' + theQuote.Name + '.pdf',
            body = theBlob);

 It fails at the line theBlob = pdfPage.getContent(); when called from the test method, otherwise it works fine. Error message is:

System.VisualforceException: List has no rows for assignment to SObject

The quotePDF page uses the same controller and I was wondering if that causes the issue. Maybe the test cannot handle another instance of the same controller? The PageReference for the pdfPage is created correctly


here is the test method:


		PageReference pageRef2 = Page.quoteSend;
		quoteLineEdit_v1 editController2 = new quoteLineEdit_v1();