You need to sign in to do that
Don't have an account?
Kanagaraj Arjunan 11
expecting right square bracket, found 'OR'
Hi All
When i save the Apex class it shows error like " expecting right square bracket, found 'OR' " in below i have given the soql query. if anyone konw about this issue please help me.
List<Asset> Assestobj = [SELECTName,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Status from Asset where Lease_Start_Date__c <=: date.today().format() AND Actual_End_Date__c >=: date.today().format() AND Status ='Active Lease' OR Status= 'Future Lease'];
When i save the Apex class it shows error like " expecting right square bracket, found 'OR' " in below i have given the soql query. if anyone konw about this issue please help me.
List<Asset> Assestobj = [SELECTName,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Status from Asset where Lease_Start_Date__c <=: date.today().format() AND Actual_End_Date__c >=: date.today().format() AND Status ='Active Lease' OR Status= 'Future Lease'];
You need to use parentheses to define the order in which fieldExpressions are evaluated. Change your query like below
List<Asset> Assestobj = [SELECTName,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Status from Asset where (Lease_Start_Date__c <=: date.today().format() AND Actual_End_Date__c >=: date.today().format()) AND (Status ='Active Lease' OR Status= 'Future Lease')];
http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select_dateformats.htm
List<Asset> Assestobj =[SELECTName,Account_Address__c,Account.Name,AccountId,Service_Contract_Provider__c,Product2Id,Product2.Name,Product_Description__c,Lease_Start_Date__c,Actual_End_Date__c,Statusfrom Asset where Lease_Start_Date__c <= TODAY AND Actual_End_Date__c >= TODAY AND (Status ='Active Lease' OR Status= 'Future Lease')];