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
SYM12SYM12 

Error: Invalid field Opportunity_Rebate__r for SObject Opportunity

I am writing a simple VF template 

 

Getting an error while saving ( Error: Invalid field Opportunity_Rebate__r for SObject Opportunity)

 Opportunity_Rebate is a custom related list and Master Detail with the Opportunity

i have tried all the options(Opportunity_Rebate__c ,Opportunity_Rebates__c,Opportunity_Rebates__r,Opportunity_Rebate__r)

 

<messaging:emailTemplate subject="testing"
recipientType="Contact"
relatedToType="Opportunity"
subject="Rebates for opportunities: {!relatedTo.name}">

<messaging:smileytongue:lainTextEmailBody >
Dear {!recipient.name},
 
Below is a list of Opportunities Rebates related to Opportunity: {!relatedTo.name}

              [ Discount ] - [ Subject ] - [ Email ] - [ Status ]
<apex:repeat var="cx" value="{!relatedTo.Opportunity__Rebate__r}">
              [ {!cx.Discount__c} ]

</apex:repeat>

</messaging:smileytongue:lainTextEmailBody>
</messaging:emailTemplate>

 

Any suggetions!!Do i need to add somting else

 

Thnaks

Best Answer chosen by Admin (Salesforce Developers) 
XactiumBenXactiumBen

On your Opportunity Rebate custom object click on the master detail field to the Opportunity and check the child relationship name.  This is what you should be using (followed by __r) to get the records from a visualforce page.

 

If you're doing that already then I assume visualforce templates don't allow access to child records...

All Answers

XactiumBenXactiumBen

On your Opportunity Rebate custom object click on the master detail field to the Opportunity and check the child relationship name.  This is what you should be using (followed by __r) to get the records from a visualforce page.

 

If you're doing that already then I assume visualforce templates don't allow access to child records...

This was selected as the best answer
SYM12SYM12

It worked :)  , Actually i havnt defined any Child relationship name ;), after defining the relationship name to OpportunityRebates and using the OpportunityRebates__r worked

 

Thanks :)