+ Start a Discussion
Morino Italis 8Morino Italis 8 

Display Data from Extension Controller Apex Salesforce

I need to display in a visualforce page the child date related to a parent based on some criteria on the child. In other terms i want 
 to have All the Container__c with status__c 'New' related to Account through a button placed in the layout page of Account.   
 I dot not find any error message but the criteria is not take effect as it is in the clause WHERE in the SOQL.

Here is my Extention Controller:
public with sharing class ContainerShipmentControllerExtension{

    public ContainerShipmentControllerExtension(ApexPages.StandardController controller) {

    }

public List<Container__c> Records {get; set;}
public ContainerShipmentControllerExtension(){
Records =
[select Pkl__c, Invoice__c, Size_in_feet__c, Description__c, 
Bill_of_Lading__c, Demurrage_begins__c, Brocker__c
 FROM Container__c WHERE Statut__c ='New'];
}
}

// my Visualforce page is:
<apex:page renderAs="pdf" showHeader="false" sidebar="false"  applyBodyTag="false" standardStylesheets="True" standardController="Account" extensions="ContainerShipmentControllerExtension"> 

<head>
        <style type="text/css" media="print">
        
        @page {
                size: landscape;
            }
            
            
            .pagenumber:before {
            content: counter(page);
            }
            
            .pagecount:before {
            content: counter(pages);
            }
        </style>
    </head>
    <div class="head">        
        <div class="col logo">
            <apex:image url="{!$Resource.LogoFFP}" width="140" height="60"/>
        </div>
        <div class ="col name"> 
            <h2>
                FOOD FOR THE POOR - {!Account.Name}
            </h2>           
            <h6>
                14, Mapou Rte. Nationale #1, Cap Haitien, Haiti <br/>
                Tels:(+509)2208-9960/3409-5328
            </h6>
        </div>        
    </div>
    
    <h3>Shipment Update </h3>
    

 
 <br/> <br/>
 <table width="100%"> 
 <tr> 
 <th>Ref#</th> 
 <th>Lead/PO</th>
 <th>Invoice#</th> 
 <th>Size</th>
 <th>Shipper</th> 
 <th>Description</th> 
 <th>Bill of Lading No</th>
 <th>On Wharf</th> 
 <th>Inv Florida</th> 
 <th>Sailing</th> 
 <th>ETA</th>
 <th>Demurrage</th> 
 <th>Broker</th> 
 <th>Comment</th>
 <th>Consignee</th> 
 </tr> 
 <apex:repeat var="c" value="{!Account.Containers__r}"> 
 <tr>
 <td>{!c.Pkl__c}</td>
 <td>{!c.PO__c}</td>
 <td>{!c.Invoice__c}</td>
 <td>{!c.Size_in_feet__c}</td>
 <td>{!c.Description__c}</td>
 <td>{!c.Bill_of_Lading__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c} </td>
 <td>{!c.Consignee__c}</td>
 <td>{!c.Demurrage_begins__c}</td>  
 <td>{!c.Brocker__c}</td>
 <td>{!c.Comments__c}</td>
 <td>{!c.Consignee__c}</td> 
  </tr>
 </apex:repeat>
 </table> 
 
  <div class="footer">
        <div>       
            Printed by :  {!$User.FirstName} {!$User.LastName} <apex:outputtext value="{0, date, long}">
        <apex:param value="{!NOW()}"></apex:param>
    </apex:outputtext> <br/>
            As often as you did it for one of my  least brothers, you did it for me. Matthiew 25:40 <br/>
              </div>
    </div>     
</apex:page>

 
Best Answer chosen by Morino Italis 8
Nayana KNayana K
public with sharing class ContainerShipmentControllerExtension{

public List<Container__c> Records {get; set;}
    public ContainerShipmentControllerExtension(ApexPages.StandardController controller) {
Records =
[select Pkl__c, Invoice__c, Size_in_feet__c, Description__c, 
Bill_of_Lading__c, Demurrage_begins__c, Brocker__c
 FROM Container__c WHERE Statut__c ='New' AND Account__c =: controller.getId()];
    }


}

Update the controller like above. I have modified the soql to have account filter in where clause. Replace Account__c with respective field api name

Change the page apex:repeat statement like below:
<apex:repeat var="c" value="{!Records}">


 

All Answers

Nayana KNayana K
public with sharing class ContainerShipmentControllerExtension{

public List<Container__c> Records {get; set;}
    public ContainerShipmentControllerExtension(ApexPages.StandardController controller) {
Records =
[select Pkl__c, Invoice__c, Size_in_feet__c, Description__c, 
Bill_of_Lading__c, Demurrage_begins__c, Brocker__c
 FROM Container__c WHERE Statut__c ='New' AND Account__c =: controller.getId()];
    }


}

Update the controller like above. I have modified the soql to have account filter in where clause. Replace Account__c with respective field api name

Change the page apex:repeat statement like below:
<apex:repeat var="c" value="{!Records}">


 
This was selected as the best answer
Morino Italis 8Morino Italis 8
Thank you. Works perfectly!!!