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
DevSFDevSF 

list error in visualforce page

Hi friends,

Hello everyone,
I am creating an invoice PDF.
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).

I was unable to retrieve child(Invoice_product__c) fields on invoice__c.

Error : Error: Unknown property 'VisualforceArrayList.Quantity__c'

My CODE :

<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.Invoice_Products_r.Quantity__c}"/></td>

I could not take repeat value as {!Invoice.Invoice_Product__c} because evenly i am using invoice fields also.

I have checked with all these things but its not working.

1) invoice__c.Invoice_product__r.  ===========> error : Unknown property 'VisualforceArrayList.Quantity__c'
2) Inv.Invoice_products__r  ===================> Error : Unknown property 'Integer.Invoice_Products__r'
3) created a list in my controller and used its instance (i.Quantity__c)  =======>  Unknown property 'Invoice__cStandardController.i


How do i resolve this.

How can we use invoice_product fields on Invoice.

 Please can anyone help me out of this...!
 
Lalitha Trail HeadLalitha Trail Head
Assuming you need Invoice_Product records only for one Invoice, try doing below:

public class myController{
    public List<Invoice_Products__c> invoicesProList {get;set;}
    public String invoiceId;
    
    public class myController(){
        invoicesProList = new List<Invoice__c>();
        invoicesProList = [select id, Quantity__c from Invoice_Products__c Where Invoice__c = :invoiceId];
    }
}

where variable invoiceId stores the actual Id of the invoice for which you want the invoice product. You have replace that with actual id.
Let me know if this helps.