I created the following to create Quote records and PDFs for all of them. The code runs up until QuotePDF.Document = QuotePage.getContentAsPDF();
and then just stops, with no errors of any kind. The quote records which were already inserted do not actually show up in SF. Never seen such an empty failure with no message before. Any ideas?
public class EmailPDFQuote implements Queueable, Database.AllowsCallouts {
public List<Opportunity> Opps;
public void execute(QueueableContext context) {
system.debug('Opps = '+Opps);
Quote [] QuotesToInsert = new List<Quote>();
for(Opportunity Opp: Opps){
Quote Q = new Quote(Name = Opp.Name, OpportunityID = Opp.ID);
QuotesToInsert.add(Q);
}
system.debug('QuotesToInsert = '+QuotesToInsert);
try{
insert QuotesToInsert;
system.debug('QuotesToInsert = '+QuotesToInsert[0].Id);
}
catch(DMLexception e){
system.debug(e);
}
QuoteDocument [] PDFs = new List<QuoteDocument>();
system.debug('QuotesToInsert = '+QuotesToInsert);
for(Quote Q: QuotesToInsert){
PageReference QuotePage = new PageReference('/quote/quoteTemplateDataViewer.apexp?id='+Q.Id+'&summlid=0EH1Y000000zeer'); //quoteUrl +='&headerHeight=190&footerHeight=188&#toolbar=1&navpanes=0&zoom=90';
system.debug('QuotePage = '+QuotePage);
QuoteDocument QuotePDF = new QuoteDocument();
system.debug(QuotePDF);
QuotePDF.Document = QuotePage.getContentAsPDF(); //Blob b = pr.getContentAsPDF();
QuotePDF.QuoteId = Q.Id;
system.debug(QuotePDF);
PDFs.add(QuotePDF);
system.debug(QuotePDF);
}
system.debug('PDFs = '+PDFs);
try{
insert PDFs;
system.debug('ok');
}
catch(DMLexception e){
system.debug(e);
}
}
}