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
Nathan WylderNathan Wylder 

visualforce email template - Invalid Field for SObject Opportunity

Here is my code. I can not even save this because the related object is not being located. 
I'm trying to generate a list of related payments for an Opportunity. (not sure if it matters, but our org renamed Opportunities to Income)...what's going on? I keep getting this message: "Error: Invalid field OppPayments for SObject Opportunity"
 
<messaging:emailTemplate 
recipientType="Contact" 
relatedToType="Opportunity"
subject="Payment report for Opportunity: {!relatedTo.name}"
replyTo="n.wylder@ifiusa.org">
    <messaging:htmlEmailBody>
        <html>
            <body>

            <p>Dear {!recipient.name},</p>
            <p>Below is a list of payments related to {!relatedTo.name}.</p>
            <table border="0" >
                <tr>
                    <th>Case Number</th><th>Origin</th>
                    <th>Creator Email</th>
                </tr>
                <apex:repeat var="cx" value="{!relatedTo.OppPayments}">
                <tr>
                    <td><a href = 
                        "https://na77.salesforce.com/{!cx.id}">{!cx.Name}
                    </a></td>
                    <td>{!cx.Designation__c}</td>
                    <td>{!cx.npe01__Payment_Amount__c}</td>
                </tr>
                </apex:repeat> 
            </table>
            <p/>
            <center>
                <apex:outputLink value="http://www.salesforce.com">
                    For more detailed information login to Salesforce.com
                </apex:outputLink>
            </center>
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 
Marcelo CostaMarcelo Costa
Hey Nathan...
I guess the {!relatedTo.OppPayments} is giving you the error as the OppPayments is not a standard salesforce field, I think It would be expecting either a __c in the end of the Field Name or a __r in case it is a relationship.
Make sure the field name is right for thye sObject Type...
Good Luck!
Gina Szafraniec 13Gina Szafraniec 13
This is what you should use <apex:repeat var="cx" value="{!relatedTo.npe01__OppPayment__r}">

You need to add the namespace prefix for the managed package on the object.