I am trying to save a visualforce email template that has both plain text and html elements-- I just tried saving a plain text version to confirm the error is not being caused by an HTML nesting/labeling issue and got the same error with just my plain-text email:
Error: Invalid field Opportunity for SObject Opportunity
Here is the (scrubbed) Visualforce plainText:
<messaging:emailTemplate recipientType="Contact"
relatedToType="Opportunity"
subject="Closed Won! with {!relatedTo.Account}">
<messaging:plainTextEmailBody>
Congrats Team!
We have just signed {!relatedTo.Account} to a new Agreement.
{!relatedTo.Owner}, please confirm existing opportunities are properly related to this parent opportunity.
Effective Start Date: {!relatedTo.Effective_Date__c}
Sales Lead: {!relatedTo.Sales_Owner_Field_Updater__c}
Client: {!relatedTo.Account}
Opportunity Name: {!relatedTo.Name}
Opportunity Type: {!relatedTo.Type}
Below is a list of Related Opportunities to the Opportunity
Opp Link | Amount | Stage | Opp Type
<apex:repeat var="oppx" value="{!relatedTo.Opportunity}">
https://na12.salesforce.com/{!oppx.id} | {!oppx.Amount} | {!oppx.Stage} | {!oppx.Primary_Media_Opportunity__c}
</apex:repeat>
Opportunity details: https://na12.salesforce.com/{!relatedTo.Id}
Account Details: https://na12.salesforce.com/{!relatedTo.AccountId}
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Not sure why this is Error'ing out on me, I am not seeing an 'Opportunity' field being referenced anywhere at the Merge Field level, is this being caused by my markup trying to source related Opportunity records?