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
bjzhubjzhu 

VF email template related lists

Hi,

 

I'm working on a VF email template and trying to output a couple related objects.

 

I want the recipient to be a Contact and I want to output variables from a "Buyer_Listing__c", and "Business_c" object, both of which are related lists for contact via a lookup field.

I also want to output a "Buyer_Listing_Categories__c" object that is master-detail with "Buyer_Listing__c" of that contact. Does anyone know how to accomplish this?

 

I looked around and found some suggestions but haven't gotten it to work:

 

 

-------------

 

 

<messaging:emailTemplate recipientType="Contact"
    subject="Test"
    relatedToType="Contact"
    replyTo="support@acme.com">
    
<messaging:htmlEmailBody >        
    <html>
        <body>
        <apex:repeat var="cy" value="{!relatedTo.Buyer_Listing__r}">
            <p>Asking Price: ${!cy.Listing_Price__c}.</p>
         </apex:repeat>
            <p><u>Business Identity and Location</u></p>
            <p>{!cy.Listed_Business__c}.</p>
         </apex:repeat>

 

Using apex:repeat seems like a really rough workaround, the other option is to change relatedToType = "Buyer_Listing_Categories__c", but then I can't find a way to get the "Business__c" object data.

amr.rsamr.rs

Hi,

 

If you have relationship b/w two objects then you can just access with "." 

 

Like Oppurtunity.Product

 

Eg: {!relatedTo.Account.ShippingPostalCode}

 

Regards,

AMR.