You need to sign in to do that
Don't have an account?

Query Child Fields on Parent (Visualforce)
Hi Friends,
I have two custom objects
1) Invoice__c
2) Invoice_Product__c
These 2 objects have master detail relationship between them (Invoice_Product__c is child object)
Here, i am writing a visualforce page on parent object (Invoice__c) where i need to get the values of my child object (Invoice_Product__c).
My Page :
<apex:repeat value="{!Invoice__c}" var="inv" id="theRepeat">
<tr style="font-size:16px;height:300px;vertical-align:text-top;Font-family:Verdana,Arial;">
<td style="border-left:1px solid;border-top:none;border-right:none;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Quantity__c.Invoice_Product__r}"/></td>
<td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Product_Name_del__c.Invoice_Product__r}"/></td>
<td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.orderDiscount.Invoice_Product__r}" /></td>
The Highlighted fields are from child object (Invoice_Product__c)
The error i was geeting was ::
"Unknown property 'Integer.Invoice_Product__r'
How do I get the fields of (Invoice_Product__c) on my page.
Any help would be appriciated..!
I have two custom objects
1) Invoice__c
2) Invoice_Product__c
These 2 objects have master detail relationship between them (Invoice_Product__c is child object)
Here, i am writing a visualforce page on parent object (Invoice__c) where i need to get the values of my child object (Invoice_Product__c).
My Page :
<apex:repeat value="{!Invoice__c}" var="inv" id="theRepeat">
<tr style="font-size:16px;height:300px;vertical-align:text-top;Font-family:Verdana,Arial;">
<td style="border-left:1px solid;border-top:none;border-right:none;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Quantity__c.Invoice_Product__r}"/></td>
<td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Product_Name_del__c.Invoice_Product__r}"/></td>
<td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.orderDiscount.Invoice_Product__r}" /></td>
The Highlighted fields are from child object (Invoice_Product__c)
The error i was geeting was ::
"Unknown property 'Integer.Invoice_Product__r'
How do I get the fields of (Invoice_Product__c) on my page.
Any help would be appriciated..!
If you just want to show child related list you can use 'apex:relatedList' in vf page.
Second way is:
1. Create controller extension for your VF page.
2. Create list collection variable in controller to store all its 'Invoice_Product__c' records and use this list in 'apex:repeat'.
Please check.
Instead of using "{!inv.Quantity__c.Invoice_Product__r}" use this "{!inv.Invoice_Product__r.Quantity__c}"
As you said that Quantity__c is a field of Invoice_Product__r then to access record from child we use RelationshipName.fieldName.
Regards,
Santosh
Are you able to solve the issue? Please let me know if you need more information or help on this.
Adding the Child Relationship Name with '__r'
Go to Child Object -> Field that relates to Parent object click on it -> See the value of Child Relationship Name
Copy this value, add "__r" into apex code:
Example: