Guest User

Untitled

a guest
May 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Opportunity openOpp = [
  2. SELECT Id
  3. FROM Opportunity
  4. WHERE IsClosed = false
  5. LIMIT 1
  6. ][0];
  7.  
  8. Quote newQuote = new Quote(
  9. OpportunityId = openOpp.Id,
  10. Name = 'doesn't matter'
  11. );
  12.  
  13. insert newQuote;
  14.  
  15. // You can't query this object so you have to hard code a quote template ID
  16. // We use a custom setting
  17. Id templateId = '';
  18.  
  19. String url = '/quote/quoteTemplateDataViewer.apexp?id=' +
  20. newQuote.Id + '&summlid=' + templateId;
  21.  
  22. PageReference contentSource = new PageReference(url);
  23. Blob pdf = contentSource.getContentAsPDF();
Add Comment
Please, Sign In to add comment