• DPC3
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi everyone -

I'm trying to use the example of a VisualForce Email Template on Accounts with related Cases to create an email for one custom object and its related list items.  Referencing the first object is straightforward, but I haven't been able to figure out how to reference the related list.

Code:
<messaging:emailTemplate subject="A foo is required for this case; Do not reply to this email." recipientType="User" relatedToType="foo__c">
<messaging:plainTextEmailBody >

   Case/foo Number: {!relatedTo.Case_Number__c}
   Subject: {!relatedTo.Subject__c}
   ...
   // Here's where the trouble occurs, where foo_item__c is an individual
   // item in a related list
   <apex:repeat var="cx" value="{!relatedTo.foo_Line_Item}">
       {!cx.Detail_Number__c} - {!cx.Replacement_Component__c}
   </apex:repeat>

   // whether I use foo_Line_Item__c, foo_Line_Items, foo_Line_Item__cs - nothing seems to apply


Looking at the schema, the foo__c child object name is foo_Line_Item__c.

Thoughts?
 

My email template (below) works fine when using the "preview" function to populate the Recipient (WhoID) and RelatedTo (WhatID)  - but when a workflow rule triggers the emai lto be sent, it comes back blank as if it's not resolving the who or what correctly. .

Code:
<messaging:emailTemplate recipientType="Contact"
    relatedToType="Account"
    subject="Your website Access"
    replyTo="anaddress@us.com" >

    <messaging:htmlEmailBody >        
    <html>
        <body>
        <p>Hello {!recipient.name}--</p>
        <p>Here is a list of the website access you users currently have for account {!relatedTo.name}:</p>
    <apex:datatable cellpadding="5" var="cts" value="{!relatedTo.Contacts}">
        <apex:column value="{!cts.Name}" headerValue="Name"/>
        <apex:column value="{!cts.Seat_Holder__c}" headerValue="Website Program Access"/>
        <apex:column value="{!cts.Email}" headerValue="Email" />
        <apex:column value="{!cts.Phone}" headerValue="Phone" />
    </apex:datatable>
        </body>
    </html>
    </messaging:htmlEmailBody> 
</messaging:emailTemplate>



I created a simple workflow rule that's called whenever a contact is edited. The workflow rule uses an email alert. The email Alert uses this template. I've checked to make sure the email template is for Contact objects, and that the Recipient is specified as Email Field: Email.

I must be missing something obvious..... any ideas?




Message Edited by icemft1976 on 10-24-2008 09:28 AM