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
Mana YaghmaiMana Yaghmai 

Unknown property 'VisualforceArrayList.CommercientSF8__INVNUMBER__c'

Hello,

I am trying to create my first VF page that has a table, the first field of the first column is a child of Account (Account.name) . the second one (Invoice Date) is a child of that child. but for the second one I am getting this error. I tried different things but it is not working. the second part of my code is the other way that I tried but getting errors.

Would you please help me with that?

Here is my page:

<apex:page standardController="Account" readOnly="true" renderAs="pdf">
<div class="bPageBlock">
    <div class="pbBody" style="padding: 0; margin: 0; vertical-align: top; color: #000; display: block;">
        <table class="detailList" border="0.5" cellpadding="0" cellspacing="0" >
                <tbody>
                    <tr> 
                        <td class="labelCol">Account</td>
                        <td class="dataCol"  id="Acc_cell">
                            <div id="Acc_inner">
                                <apex:outputlink value="/{!Account.Name}">{!Account.Name}</apex:outputlink>
                            </div>
                        </td>
                        
                        <apex:variable var="inv" value="{!Account.CommercientSF8__SAGE300_Invoice_Headers__r}"/>
                        
                        <td class="labelCol">Invoice Date</td>
                        <td class="dataCol" >
                            <div id="inv_inner">
                              <apex:outputlink value="/{!inv.CommercientSF8__INVNUMBER__c}">{!inv.CommercientSF8__INVNUMBER__c </apex:outputlink>
                            </div>
                        </td>
                    </tr>
                </tbody>
         </table>
    </div>
</div>


<apex:pageBlock>
<apex:pageBlockSection title="SAGE300 Invoice Lines">
    <apex:pageBlockTable value="{!CommercientSF8__SAGE300_InvoiceHeader__c.CommercientSF8__SAGE300_Invoice_Lines__r}" var="inv2">
        <apex:outputField value="{!inv2.Name}"/>
        <apex:outputField value="{!inv2.CommercientSF8__DESC__c}"/>
        <apex:outputField value="{!inv2.CommercientSF8__PRIUNTPRC__c}"/>
        <apex:outputField value="{!inv2.CommercientSF8__QTYSHIPPED__c}"/>
    </apex:pageBlockTable>
 </apex:pageBlockSection>
</apex:pageBlock>
John TowersJohn Towers
Your problem is here:
 
<apex:variable var="inv" value="{!Account.CommercientSF8__SAGE300_Invoice_Headers__r}"/>

CommercientSF8__SAGE300_Invoice_Headers__r is a list of child records, not the records themselves. So when you do this:
 
<apex:outputlink value="/{!inv.CommercientSF8__INVNUMBER__c}">{!inv.CommercientSF8__INVNUMBER__c </apex:outputlink>

You're trying to access 'CommercientSF8__INVNUMBER__c' on a *list* instead of a specific record.

You need to either pull a specific element from the list or loop over the list before you can pull specific values from it.
Mana YaghmaiMana Yaghmai
Hello John,

Thank you for your answer. So how can I loop over the list before pulling that specific value ? Because I have a list of companies and each company has 1000 of invoices , and what i want to do is when then click on a invoice number in a page that shows the list of invoices , it goes to a pdf page for that invoice and shows this table.
I searched and I found <apex:repeat> , even though I am not sure how to use it.
John TowersJohn Towers
<apex:repeat> is exactly what you want to loop over that list. You can use it like this:
<apex:repeat value="{!Account.CommercientSF8__SAGE300_Invoice_Headers__r}" var="inv">
     <apex:outputlink value="/{!inv.CommercientSF8__INVNUMBER__c}">
          {!inv.CommercientSF8__INVNUMBER__c}
     </apex:outputlink>
</apex:repeat>

For <apex:repeat> the "value" attribute is some sort of list to loop over. The 'var' is the variable that represents each item of that list as you loop over it.

Whatever you put inside of the repeat block will repeat for each item in the list. So when you use "{!inv.CommercientSF8__INVNUMBER__c}" it will actually use the value for that item in the list.
 

Mana YaghmaiMana Yaghmai
I added this piece of code to my VF page code but what i see now in is all my invoice numbers in rows. as you can see in the screenshot. User-added image

Here is my code:

<td class="labelCol">Invoice Number</td>
                        <td class="dataCol">
                            <div id="invnum_inner">        
                                <apex:repeat value="{!Account.CommercientSF8__SAGE300_Invoice_Headers__r}" var="inv">
                                     <apex:outputlink value="/{!inv.CommercientSF8__INVNUMBER__c}">
                                         {!inv.CommercientSF8__INVNUMBER__c}
                                     </apex:outputlink>
                                </apex:repeat>
                            </div>
                        </td>


Am i missing something?
John TowersJohn Towers
That makes sense given the code you have. Your <apex:repeat> loops over your invoices and prints out each invoice number as a link inside of that second <td> element. I'm not clear on how you're expecting that to look, though. Are you wanting each invoice number to be it's own row in the table?
Mana YaghmaiMana Yaghmai
Sorry if I am not clear. what I need is a table for each invoice. so I want only the invoice number related to that specific invoice to show up in my table.
I want to create something like this:

User-added image
Mana YaghmaiMana Yaghmai
So the structure is like this :

There is an Account, in Account I have Invoice Header(CommercientSF8__SAGE300_InvoiceHeader__c) which has its own fields and the child of Invoice Header is (CommercientSF8__SAGE300_InvoiceLine__c).

First I show Account.name
Then, I want to show Invoice number which is a field in Invoice Line. (Invoice line is a child of a child of Account) 

I hope I could clarify it well.
John TowersJohn Towers
Okay, I think I get it. Try something like this:
 
<apex:repeat value="{!Account.CommercientSF8__SAGE300_Invoice_Headers__r}" var="inv">
     <table class="detailList" border="0.5" cellpadding="0" cellspacing="0" >
                <tbody>
                    <tr> 
                        <td class="labelCol">Account</td>
                        <td class="dataCol"  id="Acc_cell">
                            <div id="Acc_inner">
                                <apex:outputlink value="/{!Account.Name}">{!Account.Name}</apex:outputlink>
                            </div>
                        </td>
                        <td class="labelCol">Invoice Date</td>
                        <td class="dataCol" >
                            <div id="inv_inner">
                              <apex:outputlink value="/{!inv.CommercientSF8__INVNUMBER__c}">{!inv.CommercientSF8__INVNUMBER__c </apex:outputlink>
                            </div>
                        </td>
                    </tr>
                </tbody>
         </table>
</apex:repeat>

That loops through each of your invoices and creates a table with the account name and invoice information. You may need to adjust a little to pull the information you want from the invoice but I think it will get you close to where you want.
Mana YaghmaiMana Yaghmai

Thank you again John , I am not able to see the result of my changes because of this error "Response size exceeded 15MB organization limit ".

John TowersJohn Towers
This happens when your page is too large. The response size for the page is limited to 15MB. If your HTML, JS, etc. is more than that, you'll see that error.

The extra HTML in my last response is repeated for *every* invoice so if there are a lot of them it will make the page too large.

There are things you can do to limit this. One would be to minimize the markup - remove any unnecessary DOM elements in that loop.

There are more suggestions in this answer (http://salesforce.stackexchange.com/questions/12734/visualforce-response-size-exceeded) on the Salesforce Stack Exchange.
Mana YaghmaiMana Yaghmai

So you mean that <apex:repeat> here makes the details for all invoices ? or just the one that I clicked on from Invoice Header ?

My page is already a readOnly page. I tried to remove the unnecessary <div></div> that I used for table cells, still I am getting the error . my first table has 9 fields and my second one has 4 fields. 

John TowersJohn Towers
Sorry I was unclear. The <apex:repeat> loops over the child Invoice Headers for the account and shows those details. Since there are quite a few of them, the page is too large.

Making the page readOnly won't help here because that only affects the number of rows you can return from a SOQL query (up to 1,000,000) and the number of items you can loop over in <apex:repeat> (up to 10,000).

There is still an overall limit of 15 MB for the total response size of the page. It almost certainly stems from looping over all possible Invoice Headers for the account. Can you limit how many you're returning and page them? Or only show the most recent?
Mana YaghmaiMana Yaghmai
I think <apex:repeat> is not what I need. because with apex:repeat. I get all the values for that specific field. but what I need is when I pick any invoice number from header table. it goes to a table that has all the information related to that specific invoice. but what I see now is a table that has all the invoice names in it. so if i want to show it by screenshots here is what i want :

first table is Invoices_Header which is a child of Account. So when you click on the Name in this table you should go to another page which has a table in it. (I already have this table up and running)

User-added image

Second table has the information of Invoices_Line which is a child of Invoices_Header 

User-added image
so i want it to take the Account.name and that specific Invoice number and so on .... same thing for the second table (SAGE300 invoices line) I need the Name of that product,description,...  which are fields in Invoices_Line. ( here some fields are empty just because I entered the values by hand to show you what i need, but if it works all the fields suppose to get their values automatically)
Mana YaghmaiMana Yaghmai
I was checking and I figured out that you can't have more than a level of Parent-to-child relationship but the opposite can go up to 5 levels. I tried to change the controller to Invoice header and go one level down to Invoice Line but I am keep getting this error for it ID : "
Id value 0M0150000008Pf1 is not valid for the CommercientSF8__SAGE300_InvoiceHeader__c standard controller 
"
I tried different ways to write the id, I tried :

?id= (ID on that specific Invoice header)      -->   ?id=00N1500000GCY4o&id=0011500001LFTw7
?id= (ID on that specific Invoice header) &id= (Invoice Line for that account) --> ?id=00N1500000GCY4o&id=0011500001LFTw7&id=15000005XKNO
?id= (Invoice header from Workbench )       -->   ?id=0M0150000008Pf1CAE

Would you please help me with that?

 
Mana YaghmaiMana Yaghmai
Here is the information I need in my table based on relationship (Parent-to-child):

Account(top of the tree)  ------------------------------------------------------------------------------------------------> (Account Field) Name
                   |    
                   |
                   |
                   |----------------------------->Invoice Header (Account Child)----------------------------------------> (Invoice Header Field) Invoice number 
                                                                 |                                         ----------------------------------------> (Invoice Header Field)  Order  number             
                                                                 |    
                                                                ​ |
                                                                ​ |
                                                                ​ |---------------> Invoice Line (Invoice Header Child)----------> (Invoice Line Field) Name     
                                                                                                                                               ----------> (Invoice Line Field) Description
                                                                                                                                               ----------> (Invoice Line Field) Price    
                                                                                                                                               ----------> (Invoice Line Field) Quantity