1

I can't see what I'm missing, probably because I've been staring at this for too long.

When bringing up the email template via a JS button, the text in the email template renders, but the PDF attachment does not get created via the JAVASCRIPT button.

Button Code

 location.replace('/email/author/emailauthor.jsp?retURL=/{!SBQQ__Quote__c.Id}&p3_lkid={!SBQQ__Quote__c.Id}&rtype=003&template_id=00Xn0000000QYSw&p4={!User.Email}&p5=&p24={!User.Order_Admin_Email__c}');

VF Template

<messaging:emailTemplate subject="Quote {!relatedTo.Name} Order Admin Details" recipientType="User" relatedToType="SBQQ__Quote__c">
<messaging:htmlEmailBody >
<h4>Greetings,</h4>
Attached are the required documents to process <b>Quote {!relatedTo.Name}.</b>

<h4>Details: </h4>
Account -  {!relatedTo.Account_Name_Text__c}
Special Instructions - {!relatedTo.Special_Instructions__c}

</messaging:htmlEmailBody>
<messaging:attachment renderAs="PDF" filename="Quote_{!relatedTo.Name}.pdf">
<html>
<head>Something  </head>
<body>

<c:QuoteLineEmailComponent theQuoteId="{!relatedTo.Id}" />

</body>
</html>
</messaging:attachment>    
</messaging:emailTemplate>

VF Component

<apex:component controller="QuoteLineEmailController" access="global">
<apex:attribute name="theQuoteID" type="Id" description="Id of the Quote" assignTo="{!QuoteID}"/>
<apex:outputPanel >  

         <table border="1">
             <td><b>PART #</b></td>
             <td><b>DESCRIPTION</b></td>
             <td><b>QTY</b></td>
             <td><b>UNIT PRICE</b></td>
             <td><b>DISC.</b></td>
             <td><b>NET PRICE</b></td>

         <apex:repeat value="{!QuoteLines}" var="QLI"> 
         <apex:variable id="itemlines" value="" var="itemlines">  
                <tr>
                    <td border="0">{!QLI.SBQQ__ProductCode__c}</td> 
                    <td border="0">{!QLI.Product_Name_and_Description__c}</td> 
                    <td border="0">{!QLI.SBQQ__Quantity__c}</td> 
                    <td border="0">{!QLI.SBQQ__ListPrice__c}</td> 
                    <td border="0">{!QLI.Discounts__c}</td> 
                    <td border="0">{!QLI.SBQQ__NetPrice__c}</td> 
                </tr>    

          </apex:variable>  
          </apex:repeat>
         </table>
    </apex:outputPanel>

Apex Controller public class QuoteLineEmailController {

public id QuoteID {get;set;}

public list<SBQQ__QuoteLine__c> getQuoteLines()
{

      list<SBQQ__QuoteLine__c> QLI = [SELECT    Name, SBQQ__ProductCode__c, Product_Name_and_Description__c, SBQQ__Quantity__c, SBQQ__ListPrice__c, 
                                      Discounts__c, SBQQ__NetPrice__c
      FROM SBQQ__QuoteLine__c WHERE SBQQ__Quote__c = :QuoteID ORDER by Name];

      return QLI;
}

}

2 Answers 2

0

After some research it looks as though everything I wrote is correct, except for the fact that Javascript buttons can't render objects (pdf).

Instead a webservice needs to be created: https://developer.salesforce.com/forums/?id=906F00000009BDFIA2

0

Actually, did a little more research and found that by adding

&new_template=1

To the javascript button renders the attachment as expected.

New JScript button

location.replace('/email/author/emailauthor.jsp?retURL=/{!SBQQ__Quote__c.Id}&p3_lkid={!SBQQ__Quote__c.Id}&rtype=003&template_id=00Xn0000000QYSw&p4={!User.Email}&p5=&p24={!User.Order_Admin_Email__c}&new_template=1');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .