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
VK86VK86 

Displaying child fields in VF page

Hello all,

 

I have searched this forum for a better answer to the issue i am facing right now but couldn't get any.

First off, i am new to VF page development and here's my situation:

 

I am using a VF page which returns Sales Order details along with Order items (Master-Detail relationship)

I am using the following code:

<apex:repeat value="{!Sales_Order__c.Order_Item__r}" var="line">
           <tr>
               <td>{!line.Name}</td>
               <td>{!line.Unit_of_Measure__c}</td>
               <td>{!line.Qty_Ordered__c}</td>
               <td>{!line.Qty_Shipped__c}</td>
               <td>{!line.Qty_Backordered__c}</td>
               <td>{!line.Unit_Price__c}</td>
               <td>{!line.Total__c}</td>
           </tr>
       </apex:repeat>

 

but when i try to save it, i get the foolowing error msg. :   Error: Invalid field Order_Item__r for SObject Sales_Order__c

 

I saw in an other post to make use of extension class but as i am new i do not know where to start and how to write a extension class.

 

Any help regarding this is much appreciated.

 

Thanks,

VK

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

Are you sure you have the correct expression for value in the repeat?  You should be able to use repeat the way you describe. 

Should it be {!Sales_Order__c.Order_Items__r}" ?

All Answers

aballardaballard

Are you sure you have the correct expression for value in the repeat?  You should be able to use repeat the way you describe. 

Should it be {!Sales_Order__c.Order_Items__r}" ?

This was selected as the best answer
VK86VK86

Aballard,

 

Thank u so much. I though i was using the correct API name and i tried so many different things.

Appreciate it!

 

Thanks,

VK

aballardaballard

If you are unsure of the relationship name for a custom object master detail...

  go to the DETAIL object detail page in setup.

  display the custom field that defines the master detail relationship

  in the section "master detail options" look at the definition of "Child Relationship Name"  (then add an __r to it). 

 

(You can also use the force.com explorer to browse your schema and determine the same information).

VK86VK86

Thank you so much.

This helps a lot!

 

Thanks again,

VK