You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
System.QueryException: expecting a colon, found 'Paid'
Hi,
I got a task like, I need to sort a field from the table.. written the Dynamic query for it and faced the issue that i mentioned,
Error is in For Loop
I got a task like, I need to sort a field from the table.. written the Dynamic query for it and faced the issue that i mentioned,
Error is in For Loop
public String sortDir { get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; } set; } public String sortField { get { if (sortField == null) {sortField = 'Name'; } return sortField; } set; } // toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again getpayslip();} public List<payslipwrapper> getpayslip() { Payslip__c myVariable = new Payslip__c(Payment_Status__c ='Paid'); string status = myVariable.Payment_Status__c; string payrolldate = payment2.payroll_cycle_date__c; string year = payment2.payroll_cycle_year__c; soql='select id,Name,Name__c,PaymentStatus__c,Account_Number__c,Billing_Specialist__c,PayRoll_Cycle__c,Year__c,Total_Pay_for_this_period__c,Total_Pay_in_Peso__c,Payment_Status__c from Payslip__c where PaymentStatus__c !='; for(payslip__c pay : Database.query(soql + status + ' and PayRoll_Cycle__c=:'+ payrolldate + ' and Year__c=:'+ year +' order by ' + sortField + ' ' + sortDir + ' Limit 999')) // Error At this Line payslipList.add(new payslipwrapper(pay)); if(payslipList.size()== 0) { // some codes } return payslipList; }
All Answers
You are simply Great :) was stucking with this error for more than an hour :)
really appreciate. Thsnks