You need to sign in to do that
Don't have an account?

System.QueryException: unexpected token: '2020-03-10'
Hello All,
I have written a sample batch to update the field and its working but i'm nt able to cover the code coverage. I'm getting System.QueryException: unexpected token: '2020-03-10' ...
please find the snippet below.
Test Class:
Regards,
VSK98
I have written a sample batch to update the field and its working but i'm nt able to cover the code coverage. I'm getting System.QueryException: unexpected token: '2020-03-10' ...
please find the snippet below.
global class batchAccountUpdateSLA implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { Date d = system.today(); String query = 'SELECT Id,Name FROM Account where After1day__c =:' + d; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Account> scope) { for(Account a : scope) { a.SLA__c= 'Gold'; } update scope; } global void finish(Database.BatchableContext BC) { } }
Test Class:
@isTest public class batchAccountUpdateSLA_Test{ Static testmethod void batchAccountUpdateSLA_TestMethod(){ Date d = system.today().addDays(3); Account acc = new Account(); acc.name = 'Test'; acc.Fax = '12345'; insert acc; Test.StartTest(); batchAccountUpdateSLA bacth = new batchAccountUpdateSLA (); ID batchprocessid = database.Executebatch(bacth ); Test.StopTest(); } }
Regards,
VSK98
Please try to modify your start method in batch class like below:
Hope this helps! Please mark as best if it does
Thanks
All Answers
Please try to modify your start method in batch class like below:
Hope this helps! Please mark as best if it does
Thanks
I have gone through your problem.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
It will throw exception if we use above query..
Thanks for your support
Regards,
VSK98