function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SwayampatiSwayampati 

Email template is asking custom object Related to record_id

Hi ,

 

I really aprreciate your help. I have already spend 3 days looking around and can't find answer anywhere.

I have a custom object ' Sample Tracking'. I want to create a send email button and send the related list' products' to the associated customer. I created the botton with following no problem,

location.replace('/email/author/emailauthor.jsp?retURL=/{!Sample_Tracking__c.Id}&rtype=003&p2_lkid={!  Sample_Tracking__c.Recipient_ContactId__c }&template_id=00XJ0000000QD2e')

 

This is working fine. and triggering the email window. Now I created the email template with the following code. My question is, when I click on send email, the sampletracking ID is not passed to the email template. How do I do that. On the other hand when I want to test email template, it is asking for entering 'related to record' .What should I enter there.  Please help me in right direction. All i want is when I am on sample tracking page, and click the send an email, the same tracking no. should be pass to email template. and it should list out the products associated with that sample tracking no.

 

<messaging:emailTemplate subject="Testing Visualforce Email Template" recipientType="Contact" relatedToType="Sample_Tracking__c"> <messaging:HtmlEmailBody > <html>     <body>      <STYLE type="text/css">            TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }            TD  {font-size: 11px; font-face: verdana }            TABLE {border: solid #CCCCCC; border-width: 1}            TR {border: solid #CCCCCC; border-width: 1}      </STYLE>          <font face="arial" size="2">

  <p>Dear {!recipient.name},</p>       <p>Below is a list of Products and Product Descriptions cases related to the Sample Request: {!relatedTo.name}.</p> <table border="0" >         <tr >             <th>Product</th><th>Product description</th><th>Send Quantity</th><th>Cost</th>          </tr> <apex:repeat var="cx" value="{!relatedTo.Product_Samples__r}">    <tr>        <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |         <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>        <td>{!cx.name}</td>                 </tr> </apex:repeat>       </table>       <p /> </font>        </body>    </html>

</messaging:htmlEmailBody> </messaging:emailTemplate>

cloudmaniacloudmania

make sure that  Sample_Tracking__c.Id is display in the page before calling the javascript function.

And in the email template,try to type "Sample_Tracking__c.Recipient_ContactId__r" in to "related to" attiribute.

SwayampatiSwayampati

I am sorry, I am new to Visual force language. How do i achieve"

make sure that  Sample_Tracking__c.Id is display in the page before calling the javascript function."



 

I am selecting  Display Type ' Dteail Page Button', in Behavior - 'execute java script'

and in the  body ' location.replace('/email/author/emailauthor.jsp?retURL=/{!Sample_Tracking__c.Id}&rtype=003&p2_lkid={!  Sample_Tracking__c.Recipient_ContactId__c }&template_id=00XJ0000000QD2e')'



I already have Sample_Tracking__c.Id  included above. the whole thing get executed when i click the Send email button. Not sure what you mean by displaying it in the page before Java script function.

 

On the other hand in template :"Sample_Tracking__c.Recipient_ContactId__r" in to "related to" attiribute. I couldn't do this as Sample_Tracking__c.Recipient_ContactId is not a valid field. Sample_Tracking__c.Recipient_Contact__c is a valid field and i have included that.

 

 

Please help as I am stuck in here and nobody knows this language in my company and i am struggling since 4 days.

 

Appreciate your help. Please clearly specify which place i n the code I need to change  as I am getting confused.

 

Thanks you so very much for your time.

 

<messaging:emailTemplate subject="Testing Visualforce Email Template" recipientType="Contact" relatedToType="Sample_Tracking__c"> <messaging:HtmlEmailBody > <html>     <body>      <STYLE type="text/css">            TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }            TD  {font-size: 11px; font-face: verdana }            TABLE {border: solid #CCCCCC; border-width: 1}            TR {border: solid #CCCCCC; border-width: 1}      </STYLE>          <font face="arial" size="2">

  <p>Dear {!recipient.name},</p>       <p>Below is a list of Products and Product Descriptions cases related to the Sample Request: {!relatedTo.Id}.</p>       <p> {!relatedTo.Recipient_Contact__c}.</p>           <table border="0" >         <tr >             <th>Product</th><th>Product description</th><th>Send Quantity</th><th>Cost</th>          </tr> <apex:repeat var="cx" value="{!relatedTo.Product_Samples__r}">    <tr>        <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |         <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>        <td>{!cx.name}</td>                 </tr> </apex:repeat>       </table>       <p /> </font>        </body>    </html>

</messaging:htmlEmailBody> </messaging:emailTemplate>