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
Gaurav IdnaniGaurav Idnani 

page block table not displaying any records for controller extension variable

<apex:pageBlockSection collapsible="true">
<apex:pageBlockTable title="Leave record" value="{!lrs}" var="lr">
<apex:column >
<Apex:outputText value="{!lr.from_date__c}" />
</Apex:column>
 </apex:pageBlockTable>
</apex:pageBlockSection>




Controller extension for the code:

public with sharing class LeaveControllerExtension {

    public List<Leave_Request__c> lrs { get; set; }
    public LeaveControllerExtension(ApexPages.StandardController controller) {
         Leave_Request__c lr = (Leave_Request__c)controller.getRecord();
         lr.from_date__c = Date.Today();
         lr.to_date__c = Date.Today() + 1;
        
       String cui = UserInfo.getUserId() ;
       List<Leave_Request__c> lrs = [SELECT From_date__c , To_date__c , Approver__c 
                                     FROM Leave_request__c
                                    WHERE Resource__c = :cui] ;
        
    }    

}
Best Answer chosen by Gaurav Idnani
Sampath SuranjiSampath Suranji
Hi,

In your code, you are not assigning to values for the Irs list. Change the code as below,
lrs = [SELECT From_date__c , To_date__c ,Approver__c 
                                     FROM Leave_request__c
                                    WHERE Resource__c = :cui] ;

regards

All Answers

Sampath SuranjiSampath Suranji
Hi,

In your code, you are not assigning to values for the Irs list. Change the code as below,
lrs = [SELECT From_date__c , To_date__c ,Approver__c 
                                     FROM Leave_request__c
                                    WHERE Resource__c = :cui] ;

regards
This was selected as the best answer
Raj VakatiRaj Vakati
public with sharing class LeaveControllerExtension {

    public List<Leave_Request__c> lrs { get; set; }
    public LeaveControllerExtension(ApexPages.StandardController controller) {
         Leave_Request__c lr = (Leave_Request__c)controller.getRecord();
         lr.from_date__c = Date.Today();
         lr.to_date__c = Date.Today() + 1;
        
       String cui = UserInfo.getUserId() ;
      lrs = [SELECT From_date__c , To_date__c , Approver__c 
                                     FROM Leave_request__c
                                    WHERE Resource__c = :cui] ;
        
    }    

}

 
Gaurav IdnaniGaurav Idnani
Thanks @Sampath & @Raj , it works now