1

I wanted to create an email template that can be used as custom javascript button on custom object.

So i have 2 custom object : Obj1__c & Obj2__c. Neither of these objects are directly related to any standard object. Obj1(master) has m/d relationship with Obj2. Now i have create a custom javascript button on Obj1 to send email.

.toAddresses is set to "{!Obj1__c.Email__c}";

Now I wanted to crate an vf email template to show all realted records (Obj2)data in email template. But not sure about the what values should i select for "recipientType" & "relatedToType"

All the online vf templates examples have standard object as Recipient Type hence confused.

Thanks for your time!

1 Answer 1

3

Since based on Obj1, you want to display Obj2 data in the template, so approach is:

First, the recipientType also called the WhoID and secondly the relatedToType also refered to as the whatID in regular email templates. In addition, a replyTo address can be defined, so that anyone replying to the email can reply back to this address.

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Obj1__c"
    subject="Display records related to: {!relatedTo.name}"
    replyTo="[email protected]">

If you want to access Obj2 fields, use this to verify the correct relationship name from workbench (if you have any confusion)

<apex:repeat var="cx" value="{!relatedTo.Obj2__r}">
2
  • Thanks a lot for always replying to my questions!.....but neither Obj1 nor Obj2 is realted to Contact. So i am not getting logic of recipientType="Contact" . Also how can i access Obj2__c fields in email template. like <apex:repeat var="xx" value="{!relatedTo.Obj2}"> ??? Commented Feb 5, 2018 at 15:57
  • recipientType is WhoId, think about Task object, how we define WhoId and WhatId Commented Feb 5, 2018 at 16:07

You must log in to answer this question.

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