+ Start a Discussion
Deepu161Deepu161 

Variable a does not exist @ line no 38 :

public with sharing class showallTimeCatdsCtrl {

public Invoice__c objInvoices {get;set;}

public Invoice__c obj  {get;set;}
public string recordTypeId {get;set;}
public string RecordTypename{get;set;}
public string  strProjectId{get;set;}
public date fromDate{get;set;}
public date toDate{get;set;}
public List<Timecard__c> lstTimeCards {get;set;}
public List<showallTimeCatdsCtrlwrapper> TcList = new List<showallTimeCatdsCtrlwrapper>();
public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

 public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
     objInvoices = new invoice__c ();
    obj = new invoice__c ();
    recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
    
    List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
    RecordTypename = lstRecordtypeName[0].name;   
    lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];

    }
     
       public PageReference saveInvoices() {        
        strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null){
        
        lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
         TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
        return null;

          }  
       
        return null;
    }
    public PageReference getSelected()

    {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;

    }
        public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper

    {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a)

        {

           Tc = a;

            selected = false;

        }

    }



}
Swayam@SalesforceGuySwayam@SalesforceGuy
public with sharing class showallTimeCatdsCtrl {

public Invoice__c objInvoices {get;set;}

public Invoice__c obj  {get;set;}
public string recordTypeId {get;set;}
public string RecordTypename{get;set;}
public string  strProjectId{get;set;}
public date fromDate{get;set;}
public date toDate{get;set;}
public List<Timecard__c> lstTimeCards {get;set;}
public List<showallTimeCatdsCtrlwrapper> TcList = new List<showallTimeCatdsCtrlwrapper>();
public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

 public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
     objInvoices = new invoice__c ();
    obj = new invoice__c ();
    recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
    
    List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
    RecordTypename = lstRecordtypeName[0].name;   
    lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];

    }
     
       public PageReference saveInvoices() {        
        strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null){
        
        lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
         
//Update Below code
for(Timecard__c Tc : lstTimeCards)
		 {
		 TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
		 }
        return null;

          }  
       
        return null;
    }
    public PageReference getSelected()

    {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;

    }
        public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper

    {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a)

        {

           Tc = a;

            selected = false;

        }

    }



}

Updated Code ..

Hope this helps !!

--
Thanks,
Swayam
Mahesh DMahesh D
Hi Deepu161,

Please find the updated code:

(1) Corrected the code.
(2) Alignment.

 
public with sharing class showallTimeCatdsCtrl {

	public Invoice__c objInvoices {get;set;}

	public Invoice__c obj  {get;set;}
	public string recordTypeId {get;set;}
	public string RecordTypename{get;set;}
	public string  strProjectId{get;set;}
	public date fromDate{get;set;}
	public date toDate{get;set;}
	public List<Timecard__c> lstTimeCards {get;set;}
	public List<showallTimeCatdsCtrlwrapper> TcList = new List<showallTimeCatdsCtrlwrapper>();
	public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

	public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
		objInvoices = new invoice__c ();
		obj = new invoice__c ();
		recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
		
		List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
		RecordTypename = lstRecordtypeName[0].name;   
		lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];
    }
     
    public PageReference saveInvoices() {        
		strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null) {
			lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
			for(Timecard__c tc: lstTimeCards) {
				TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
			}
			return null;
        }  
       
        return null;
    }
	
    public PageReference getSelected() {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;
    }
    
	public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a) {
			Tc = a;
            selected = false;
        }
    }
}
Please do let me know if it helps you.

Note: Whenever you paste the code please use the (< >) synbol in the above pabel to paste the code.

Regards,
Mahesh

 
Deepu161Deepu161
<apex:page standardController="Invoice__c" extensions="showallTimeCatdsCtrl"  >

<apex:form >
<apex:pageBlock title="Invoices">
<apex:pageMessages ></apex:pageMessages>
<apex:pageblockSection >
<apex:inputField value="{!objInvoices.Account__c}"/>
<apex:pageblockSection >
<apex:outputlabel value="RecordType Name"></apex:outputlabel>
<apex:outputText value="{!RecordTypename }"/> 
</apex:pageblockSection>
</apex:pageblockSection>

<apex:pageblockSection >
<apex:inputField value="{!objInvoices.Status__c}"/>
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Cross_Checked_Approved__c}"/>
    <apex:inputField value="{!objInvoices.Project__c}"/> 
</apex:pageblockSection>
<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Service_Term_From__c}"/>  
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Service_Term_To__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Amount__c}"/>
    <apex:inputField value="{!objInvoices.Comments__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Check_No__c}"/>
    <apex:inputField value="{!objInvoices.Due_Date__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.CurrencyIsoCode}"/>
    <apex:inputField value="{!objInvoices.Date_Paid__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Payment_Mode__c}"/>   
</apex:pageblockSection>
<apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!saveInvoices}"/>
 <apex:commandButton value="cancel" action="{!cancel}"/>
 </apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock title="Related TimeCards" rendered="{!IF(lstTimeCards.size > 0,true,false)}">



<apex:pageblockTable value="{!lstTimeCards}" var="l" >
<apex:column >

<apex:facet name="header"> <apex:inputCheckbox >

<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>

</apex:inputCheckbox></apex:facet>

<apex:inputCheckbox value="{!Tc.selected}" id="checkedone">

<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS"/>

</apex:inputCheckbox></apex:column>

<apex:column value="{!l.Employee__c}"/>
<apex:column value="{!l.name}"/>
<apex:column value="{!l.Date_Of_Service__c}"/>
<apex:column value="{!l.Hours__c}"/>
<apex:column value="{!l.Client_Pay__c}"/>

<apex:column value="{!l.project__c }"/>

</apex:pageblockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Generate Invoice" action="{!Generate}"/>
</apex:pageBlockButtons>


</apex:pageBlock>
</apex:form>
<script>
function checkAll(cb)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("checkedone")!=-1)
inputElem[i].checked = cb.checked;
}
}    
</script>
 
</apex:page>


apex was working well.,

Unknown property 'Invoice__cStandardController.Tc'

Deepu161Deepu161
Tq @ swayam & @ mahesh
 
Mahesh DMahesh D
Hi Deepu,

Please take the latest VF page code:
 
<apex:page standardController="Invoice__c" extensions="showallTimeCatdsCtrl"  >

<apex:form >
<apex:pageBlock title="Invoices">
<apex:pageMessages ></apex:pageMessages>
<apex:pageblockSection >
<apex:inputField value="{!objInvoices.Account__c}"/>
<apex:pageblockSection >
<apex:outputlabel value="RecordType Name"></apex:outputlabel>
<apex:outputText value="{!RecordTypename }"/> 
</apex:pageblockSection>
</apex:pageblockSection>

<apex:pageblockSection >
<apex:inputField value="{!objInvoices.Status__c}"/>
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Cross_Checked_Approved__c}"/>
    <apex:inputField value="{!objInvoices.Project__c}"/> 
</apex:pageblockSection>
<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Service_Term_From__c}"/>  
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Service_Term_To__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Amount__c}"/>
    <apex:inputField value="{!objInvoices.Comments__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Check_No__c}"/>
    <apex:inputField value="{!objInvoices.Due_Date__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.CurrencyIsoCode}"/>
    <apex:inputField value="{!objInvoices.Date_Paid__c}"/>   
</apex:pageblockSection>

<apex:pageblockSection >
    <apex:inputField value="{!objInvoices.Payment_Mode__c}"/>   
</apex:pageblockSection>
<apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!saveInvoices}"/>
 <apex:commandButton value="cancel" action="{!cancel}"/>
 </apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock title="Related TimeCards" rendered="{!IF(lstTimeCards.size > 0,true,false)}">



<apex:pageblockTable value="{!TcList}" var="stcWrapper" >
<apex:column >

<apex:facet name="header"> <apex:inputCheckbox >

<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>

</apex:inputCheckbox></apex:facet>

<apex:inputCheckbox value="{!stcWrapper.Tc.selected}" id="checkedone">

<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS"/>

</apex:inputCheckbox></apex:column>

<apex:column value="{!stcWrapper.Tc.Employee__c}"/>
<apex:column value="{!stcWrapper.Tc.name}"/>
<apex:column value="{!stcWrapper.Tc.Date_Of_Service__c}"/>
<apex:column value="{!stcWrapper.Tc.Hours__c}"/>
<apex:column value="{!stcWrapper.Tc.Client_Pay__c}"/>

<apex:column value="{!stcWrapper.Tc.project__c }"/>

</apex:pageblockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Generate Invoice" action="{!Generate}"/>
</apex:pageBlockButtons>


</apex:pageBlock>
</apex:form>
<script>
function checkAll(cb)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf("checkedone")!=-1)
inputElem[i].checked = cb.checked;
}
}    
</script>
 
</apex:page>

Please do let me know if it helps you.

Regards,
Mahesh
Deepu161Deepu161
Error :'Invoice__cStandardController.TcList'
Mahesh DMahesh D
Hi Deepu,

Please use the below Class:
 
public with sharing class showallTimeCatdsCtrl {

	public Invoice__c objInvoices {get;set;}

	public Invoice__c obj  {get;set;}
	public string recordTypeId {get;set;}
	public string RecordTypename{get;set;}
	public string  strProjectId{get;set;}
	public date fromDate{get;set;}
	public date toDate{get;set;}
	public List<Timecard__c> lstTimeCards {get;set;}
	public List<showallTimeCatdsCtrlwrapper> TcList {get;set;}
	public List<Timecard__c> selectedlstTimecards = new List<Timecard__c>();

	public showallTimeCatdsCtrl(ApexPages.StandardController controller) {
		objInvoices = new invoice__c ();
		obj = new invoice__c ();
		TcList = new List<showallTimeCatdsCtrlwrapper>();
		recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
		
		List<recordtype> lstRecordtypeName = [select id,name from recordtype where SobjectType ='invoice__c' and id=:recordTypeId limit 1 ];
		RecordTypename = lstRecordtypeName[0].name;   
		lstTimeCards  = new List<Timecard__c>();
        //obj=[select id,name,CurrencyIsoCode,recordtypeid from invoice__c where recordtypeid= :recordTypeId  limit 1];
    }
     
    public PageReference saveInvoices() {        
		strProjectId = objInvoices.Project__c;   
        objInvoices.recordtypeid = recordTypeId ;
        fromDate      =     objInvoices.Service_Term_From__c; 
        todate        =     objInvoices.Service_Term_To__c;
        
        upsert objInvoices;
        
        if(strProjectId!=null) {
			lstTimeCards  =[select id, name ,project__c ,Employee__c, Date_Of_Service__c, Hours__c, invoiced__c, Client_Pay__c from Timecard__c where project__c  = :strProjectId and Date_Of_Service__c >= :fromDate  and Date_Of_Service__c  <= : todate];
			for(Timecard__c tc: lstTimeCards) {
				TcList.add(new showallTimeCatdsCtrlwrapper(Tc));
			}
			return null;
        }  
       
        return null;
    }
	
    public PageReference getSelected() {

        selectedlstTimecards.clear();

        for(showallTimeCatdsCtrlwrapper Tcwrapper : TcList)

        if(Tcwrapper.selected == true)

        selectedlstTimecards.add(Tcwrapper.Tc);

        return null;
    }
    
	public PageReference Generate(){
        PageReference pageRef = new PageReference('/apex/editable');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public class showallTimeCatdsCtrlwrapper {
        public Timecard__c Tc{get; set;}

        public Boolean selected {get; set;}

        public showallTimeCatdsCtrlwrapper(Timecard__c a) {
			Tc = a;
            selected = false;
        }
    }
}

Regards,
Mahesh