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 

Smart folks help me!! Can't pass custom object id to Email template

Hi folk,

 

Hopefully you smart guys can help me out here. I have similar problem like you. I am trying to send an email from custom object with the related list. My custom object is 'Sample Tracking'

I created an email button on custom object with the following.

 

location.replace('/email/author/emailauthor.jsp?re​tURL=/{!Sample_Tracking__c.Id}&rtype=003&p2_lkid={​!  Sample_Tracking__c.Recipient_ContactId__c }&template_id=00XJ0000000QD59&p5=')

 

I created an email template with following:

<messaging:emailTemplate subject="Sample Tracking Products and Product Descriptions" 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></t​d>        <td>{!cx.name}</td>                 </tr> </apex:repeat>       </table>       <P/> </font>        </body>    </html>

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

 

The problem I am getting is, when i click the email button the sample tracking is is not passed to the email template. And the email template don't return anything. It loads properly with contact in 'to box' of email and subjects text comes properly but the particular sample tracking page from which I click the email button is not passed to the template. So none of the related lists shows up.

 

Please suggest. I have spend about a week with no solution. Appreciate your time.

 

Thanks

Swayam

Best Answer chosen by Admin (Salesforce Developers) 
APathakAPathak

Go to create->object->Sample Tracking custom object's page . Check the Track Activites checkbox and then try.

 

If this solved your problem mark it as solved.

All Answers

APathakAPathak

Hi,

Use the below code for button:-

 

location.replace('/email/author/emailauthor.jsp?re​tURL=/{!Sample_Tracking__c.Id}&rtype=003&p2_lkid={​!  Sample_Tracking__c.Recipient_ContactId__c }&p3_lkid={!Sample_Tracking__c.Id}&template_id=00XJ0000000QD59&p5=')

 

 

If this solved your problem please mark it as answer.

 

 

SwayampatiSwayampati

Nope!! it doesn't like p3_lkid={!Sample_Tracking__c.Id}. I get the error as

 

The value of the "p3_lkid" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

 

Thats becuase the Sample_tracking doesn't come in the dropdown list of " Related to" field as it is a custom object.

 

Any suggestion...

APathakAPathak

Go to create->object->Sample Tracking custom object's page . Check the Track Activites checkbox and then try.

 

If this solved your problem mark it as solved.

This was selected as the best answer
SwayampatiSwayampati

Dear Pathak,

 

I can 't say thank you enough. I have been struglling with this since last 2 weeks. Thanks you so very much.Looks like you have a good experience in salesforce.

 

Regards

Swayam

ErikNelke1ErikNelke1

I am so glad I found this one little tid bit of Info!. It was the only thing stopping my custom button from working!

vidya pawarvidya pawar
Dear Pathak,

Thank you so much. This helped alot.

Regards,
Vidya