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
Annie LaCourtAnnie LaCourt 

Problem uisng apex:pageblock with custom objects

why does this work:
<apex:page standardController="Account" tabStyle="Account" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!Account.contacts}" var="c">
                <apex:column value="{!c.firstname}"/>
                <apex:column value="{!c.lastname}"/>
                <apex:column headerValue="Email">
                    <apex:inputField value="{!c.Email}"/>
                </apex:column>
            </apex:pageBlockTable>                       
        </apex:pageBlock>
    </apex:form>
</apex:page>

and this does not:


<apex:page standardController="Financial_Education_workshop__c" tabStyle="Financial_Education_workshop__c" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
              <apex:pageBlockTable value="{!Financial_Education_workshop__c.Workshop_Attendance__c}" var="w">
                <apex:column value="{!w.Attendee}"/>
                 <apex:column headerValue="Attendance">
                      <apex:inputField value="{!w.Attendance__c}"/>
                </apex:column>
             </apex:pageBlockTable>        
        </apex:pageBlock>
    </apex:form>
</apex:page>

Where Financial_Education_Workshop__c is a custom object and Workshop_Attendance__c is the name of a 
child relationship on another custom object. The error I am getting when I try to save the code is that
Workshop_Attendance is an invalid field on Sobject Financial_Education_workshop__c. I am trying figure out 
the correct synatx for referring to the relationship between the objects so that I can display a list of
the child records related to the parent object for editing in a grid. 

thx,
Annie
 
 
Best Answer chosen by Annie LaCourt
Ramesh KallooriRamesh Kalloori
apex:pageBlockTable value="{!Financial_Education_workshop__r.Workshop_Attendance__c}" var="w">

All Answers

Ramesh KallooriRamesh Kalloori
apex:pageBlockTable value="{!Financial_Education_workshop__r.Workshop_Attendance__c}" var="w">
This was selected as the best answer
Annie LaCourtAnnie LaCourt
Not quite but still the clue I needed!  This works:

 apex:pageBlockTable value="{!Financial_Education_workshop__c.Workshop_Attendance__r}" var="w"> 

So now I know to use r instead of c for relationships and I am sure that will apply elsewhere. thank! Annie