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
Howard WeinsteinHoward Weinstein 

Trying to Display a related List for 2 Custom Objects

I took from trailhead the simple example of taking the accounts object and showing the related contacts in a form.

I used two custom objects in my org

We have Employees (SFDC_Employee__c) and we have Reviews (SFDC_SkillsDev_Review__c)

All I am trying to do is have a form that brings up the employee with their related reviews

However I am getting an error each time I try to  reference the Id of the reviews in line 27 which is related to lines 22 to 35

Code Below
<apex:page standardController="SFDC_Employee__c">
    <apex:form>
    
    <apex:pageBlock title="Edit Employee">
        <apex:pageMessages/>

        <apex:pageBlockSection>
            <apex:inputField value="{! SFDC_Employee__c.Name }"/>    
            <apex:pageBlockSection columns="1">
    <apex:inputField value="{! SFDC_Employee__c.Name }"/>
    <apex:inputField value="{! SFDC_Employee__c.Job_Function__c }"/>        
    <apex:inputField value="{! SFDC_Employee__c.Start_Date__c }"/>        
    <apex:inputField value="{! SFDC_Employee__c.Email_Address__c }"/>
</apex:pageBlockSection>
        </apex:pageBlockSection>

        <apex:pageBlockButtons>
            <apex:commandButton action="{! save }" value="Save" />        
        </apex:pageBlockButtons>

    </apex:pageBlock>
        
        <apex:pageBlock title="Reviews">
    <apex:pageBlockTable value="{!SFDC_Employee__c.Reviews__c}" var="review">
        <apex:column>
            <apex:outputLink
                value="{! URLFOR($Action.SFDC_SkillsDev_Review__c.Edit, review.Id) }">
                Edit
            </apex:outputLink>
            &nbsp;
          
        </apex:column>
        <apex:column value="{!review.Name}"/>
        <apex:column value="{!review.Period_Review__c}"/>
        <apex:column value="{!review.Review_Type__c}"/>
    </apex:pageBlockTable>
</apex:pageBlock>
    
    </apex:form>
</apex:page>User-added image
Best Answer chosen by Howard Weinstein
Big EarsBig Ears
So, on line 24, try:
 
<apex:pageblocktable value="{!SFDC_Employee__c.Revews__r}" var="review">

 

All Answers

Big EarsBig Ears
Howard,

You may have wrongly identified the variable for the child reviews object. I would expect it to be something like "Reviews__r" rather than "Reviews__c"

Andy
Big EarsBig Ears
So, on line 24, try:
 
<apex:pageblocktable value="{!SFDC_Employee__c.Revews__r}" var="review">

 
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
Try to modify your code like below code. I hope that will help u
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
<apex:pageBlockSection title="{!a.name}"></apex:pageBlockSection>
  <apex:relatedList list="Contacts" subject="{!a.Id}"/>
<apex:relatedList list="Opportunities" subject="{!a.Id}" />
</apex:repeat>      
     </apex:pageBlock>
</apex:page>