You need to sign in to do that
Don't have an account?
suji srinivasan
How to provide constructor value for this apex class?
public class SalaryRewards {
public List <salaryInfo> lsalaryInfo{get;set;}
public List <Salary_Detail__c> salarydetail{get;set;}
public SalaryRewards(ApexPages.StandardController controller)
{
lsalaryInfo = new list <salaryInfo>();
salarydetail = new list<Salary_Detail__c>();
salarydetail =[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ];
for(integer i=0;i<System.now().month();i++)
{
salaryInfo sinfo = new salaryInfo ();
sinfo.month = datetime.newinstance(2013,1,1).addmonths(i).format('MMM');
sinfo.count = 0;
lsalaryInfo.add(sinfo);
system.debug('salary-month===>'+lsalaryInfo);
}
// lsalaryInfo = new List <salaryInfo>();
list<Salary_Detail__c> sallist =new list<Salary_Detail__c>();
list<Salary_Detail__c> salmainlist =new list<Salary_Detail__c>([SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ]);
for(Salary_Detail__c sal :salmainlist){
lsalaryInfo.add(new Salary_Detail__c(sal,BasicAllowance__c));
// how to mention value here
//error:Type requires name=value pair construction: Salary_Detail__c
system.debug('salary-month===>'+ lsalaryInfo);}
}}
public List <salaryInfo> lsalaryInfo{get;set;}
public List <Salary_Detail__c> salarydetail{get;set;}
public SalaryRewards(ApexPages.StandardController controller)
{
lsalaryInfo = new list <salaryInfo>();
salarydetail = new list<Salary_Detail__c>();
salarydetail =[SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ];
for(integer i=0;i<System.now().month();i++)
{
salaryInfo sinfo = new salaryInfo ();
sinfo.month = datetime.newinstance(2013,1,1).addmonths(i).format('MMM');
sinfo.count = 0;
lsalaryInfo.add(sinfo);
system.debug('salary-month===>'+lsalaryInfo);
}
// lsalaryInfo = new List <salaryInfo>();
list<Salary_Detail__c> sallist =new list<Salary_Detail__c>();
list<Salary_Detail__c> salmainlist =new list<Salary_Detail__c>([SELECT Id, Professional_Tax__c,BasicAllowance__c,HouseRentAllowance__c,Skill_up_Allowance__c,PF__c,SpecialAllowance__c,TotalEarnings__c,TotalDeductions__c, NetPay__c,createdDate FROM Salary_Detail__c WHERE createdDate = THIS_YEAR ]);
for(Salary_Detail__c sal :salmainlist){
lsalaryInfo.add(new Salary_Detail__c(sal,BasicAllowance__c));
// how to mention value here
//error:Type requires name=value pair construction: Salary_Detail__c
system.debug('salary-month===>'+ lsalaryInfo);}
}}
Sorry but i dont know what you are trying to do.
IF you want to add some values on the IsalaryInfo list then there are couple of ways you can add values on a list.