• Nisha Vishwasrao
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am facing the issue where PDF getting generated from VF page are blank. 
I do not have the corresponding critical update activated to treat getContentAsPDF() Methods as Callouts. 
The method getContentAsPDF() is invoked from a method SendPDF on custom controller class. And this SendPDF method is getting called as an action from a VF page.
Below is the code of this method. After upsert Survey, trigger class gets invoked on Survey object.

public static void SendPDF()
{
String AccountId = ApexPages.currentPage().getParameters().get('id');
String SurveyId = ApexPages.currentPage().getParameters().get('survey');

Survey__c[] Survey = [ SELECT Id, Name, Status__c, Send_PDF__c
FROM Survey__c
WHERE Id = :SurveyId LIMIT 1 ];

if (Survey[0].Status__c.equals('Complete') && 
(Survey[0].Send_PDF__c == null || ! Survey[0].Send_PDF__c.equals('Sent')))
{
PageReference pdfReport = Page.SurveyPg;

pdfReport.getParameters().put('id', AccountId);
pdfReport.getParameters().put('survey', SurveyId );
//System.debug(pdfReport);

Blob PDFBlob = pdfReport.getcontentAsPdf();
String PDFName = 'Survey' + Survey[0].Name + '.pdf';

Attachment attachment = new Attachment();
attachment.Body = PDFBlob;
attachment.Name = PDFName;
attachment.ParentId = SurveyId;
insert attachment;

Survey[0].Send_PDF__c = 'Sent';
upsert Survey;
}
}

We are not sending the PDF as email but instead attaching it to the survey record.
I am not directly calling the method from trigger and also do not have the critical update activated but still facing the issue.
Is there something else I need to do to make sure that getContentAsPDF() works correctly?
Hi,
We have a visualforce page for survey based on our force.com site. (http://site_URL/apex/userfeedback?id={!Account.Id})
A button on account invokes the above url.
The visualforce page uses standard controller as Account and a controller extension apex class which executes the entire functionality of the surveys.
It implements the logic to find an existing survey, if survey is already completed it shows the thank you page, it also handles the logic to skip certain questions based on answers of other questions.
There is method to find existing survey. and this method is called from visualforce page as action on the very first apex:page action parameter.
I have difficulty understanding this method. The method basically tries to parse the url to get the survey id (ApexPages.currentPage().getParameters().get('survey');) and I am unable to find out where/how is the survey id getting passed to the url.
I cannot find any code which will say something like Page.userfeedback.getParameters().put('survey', Survey.id); anywhere in the extension class or the trigger of underlying account or survey object. I also checked the URL Rewriter Class on the site which has code to add survey id for other pages of other surveys but not for the userfeedback survey.
Does anyone have any suggestion about how and where should I look for this missing code or functionality?
I do not have any documentation for this functionality but I was successfully able to understand the rest of the code.