You need to sign in to do that
Don't have an account?
Duplicate Id in List
list<VA_Allowance__c> AdjAllow = new list<VA_Allowance__c>(); list<VA_Bonus__c> bonusy =new list<VA_Bonus__c>(); list<string> bonusvaid = new list<string>(); list<Payslip__c> pays = new list<Payslip__c>(); adjbonus1 = [select name ,Adjustment__c, Adjustment_end_date__c,Acctid__c,Account_Name__c, Amount__c,New_Our_VA__c,Payslip_IDs__c,Type__c,payroll_cycle_year__c,payroll_cycle_start_year__c,Payroll_cycle_end_year__c, Adjustment_start_date__c,Adjustment_End_date1__c,Adjustment_startdate__c,Adjustment_Enddate__c,Mode__c,Bonus_creditdate__c,status__c from VA_Bonus__c where Status__c='Active' and Payroll_Adjustment_only__c=true limit 1]; adjset.addall(adjbonus); system.debug('>>>>>adjset'+adjset); adjbonus.addall(adjset); for(Payslip__c psx1 : pays) { system.debug('&&&&&&&pays'+psx1.Payslips__c); for(VA_Bonus__c bonusx : adjbonus1) { if(psx1.Payslips__c == bonusx.New_Our_VA__c&& bonusx.status__c =='active') { if(bonusx.mode__c == 'One time' && bonusx.Bonus_creditdate__c==pc.payroll_cycle_type__c && bonusx.payroll_cycle_year__c ==pc.Payroll_cycle_year__c) { Paysliplineitem__c dedpsl = new Paysliplineitem__c(); dedpsl.Payslips__c = psx1.id; dedpsl.Account__c = bonusx.Acctid__c; dedpsl.Date__c = system.today(); dedplx.add(dedpsl); if(bonusx.mode__c == 'One time') { bonusx.Payslip_IDs__c = psx1.name; bonusx.status__c = 'Inactive'; } bonusy.add(bonusx); system.debug('************bonusy'+bonusy); } if(bonusx.mode__c == 'Recurring') { date adjstartdate=date.parse(bonusx.Adjustment_startdate__c); date adjenddate = date.parse(bonusx.Adjustment_Enddate__c); if(adjstartdate <= pc.paryoll_enddate__c && adjenddate >= pc.paryoll_enddate__c) { Paysliplineitem__c dedpsl = new Paysliplineitem__c(); dedpsl.Payslips__c = psx1.id; dedpsl.Account__c = bonusx.Acctid__c; dedpsl.Date__c = system.today(); dedplx.add(dedpsl); system.debug('****adddedplx'+dedplx); if(bonusx.mode__c == 'Recurring') { if(bonusx.Payslip_IDs__c == null) { bonusx.Payslip_IDs__c = psx1.name; system.debug('>>>>> bonusx.Payslip_IDs__c'+ bonusx.Payslip_IDs__c); } else if(bonusx.Payslip_IDs__c != null) { bonusx.Payslip_IDs__c = bonusx.Payslip_IDs__c + ',' + psx1.name; if(adjenddate <=pc.paryoll_enddate__c) { bonusx.status__c = 'Inactive'; } } } } bonusy.add(bonusx); } } } } insert dedplx; update bonusy; // Error In this LineCan Anyone Suggest how to solve this?
Thanks
Try the below code i will help
All Answers
Set won't allow duplicate records in collections
Try the below code i will help
When i change code like it showed Compile Error: DML requires SObject or SObject list type:
So I again added It to list like,
But Got again Old Error... It should Remove Duplicates right..!
Thanks
may this will help you
Thanks you all guys, Especially Ramesh Kosalairaman :)
Please select the correct answer as best