I am trying to automate the generation of quote pdfs. I have found a really nice blog entry on that topic here: https://automationchampion.com/2020/06/23/getting-started-with-process-builder-part-97-now-generating-a-quote-pdf-is-a-breeze-learn-how/?fbclid=IwAR0QHkSOjk2TG9hzdthNAbJ88hQjKjGX8FuV_UicCcnT_N-sfp5PJBicXVo
Everything works fine except for the fact that pdf just turns out completely blank.
Here the code from github:
Public class generateQuotePdfDocument{
@InvocableMethod
//https://github.com/Rakeshistom/Auto-Generates-Quote-PDF
public static void LeadAssign(List<Id> quoteIds)
{
//Initialize the quote url
String quoteUrl = '/quote/quoteTemplateDataViewer.apexp?';
//Get the Quote Template Id from Custom Settings
String quoteTemplateId = Label.QuoteTemplateId;
//List variable to get all the Quote Documents
List<QuoteDocument> lstQuoteDoc = new List<QuoteDocument>();
if(!quoteIds.isEmpty() && quoteIds.size() > 0) {
for(Id quoteId :quoteIds) {
//Construct the quote URL to generate PDF
quoteUrl += 'id=' + quoteId;
quoteUrl += '&headerHeight=197&footerHeight=10';
quoteUrl += '&summlid=' + quoteTemplateId;
//call the quote url
PageReference pageRef = new PageReference(quoteUrl);
//get the quotePdf
Blob quoteBlob;
if(Test.isRunningTest()) {
quoteBlob = Blob.valueOf('Generate Pdf');
} else {
quoteBlob = pageRef.getContentAsPDF();
}
//initialze the QuoteDocument to hold the quote pdf for insertion
QuoteDocument quoteDoc = new QuoteDocument();
quoteDoc.Document = quoteBlob;
quoteDoc.QuoteId = quoteId;
lstQuoteDoc.add(quoteDoc);
}
}
if(!lstQuoteDoc.isEmpty() && lstQuoteDoc.size() > 0) {
Database.insert(lstQuoteDoc);
}
}
}
Any thoughts what might be the problem?
Label.QuoteTemplateId
pointing at a real Quote Template?