You need to sign in to do that
Don't have an account?
Craig Phoenix
Apex Batch Query Records By Last Modified
Hi,
I am building and working on an Apex Batch Class and almost got it built but for some reason I am not able to resove an error on line 4 and I am hoping someone can help me understand the error and help me with adjusting as needed?
The only item that is throwing an error is line 4 which I highlighted in code above (line where starts return Data base.getQueryLocator...
Effectively I am looking to pull all leads with last modified date greater than 30 days then update the status to Closed.
I am building and working on an Apex Batch Class and almost got it built but for some reason I am not able to resove an error on line 4 and I am hoping someone can help me understand the error and help me with adjusting as needed?
global class LeadDailyUpdater implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext bc){ return Database.getQueryLocator [select id, LastModifiedDate, Status, leadsource from Lead Where LastModifiedDate < LAST_N_DAYS:30]; } global void execute(Database.BatchableContext bc,List<lead> scope) { List<Lead> leads=new List<Lead>(); for(lead l : scope) { l.LeadSource='Closed'; leads.add(l); } update leads; } global void finish(Database.BatchableContext bc) { AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id = :bc.getJobId()]; system.debug(job); } }
The only item that is throwing an error is line 4 which I highlighted in code above (line where starts return Data base.getQueryLocator...
Effectively I am looking to pull all leads with last modified date greater than 30 days then update the status to Closed.
It seems to be a syntax error. Try below Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database_batch.htm
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
All Answers
It seems to be a syntax error. Try below Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database_batch.htm
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you