You need to sign in to do that
Don't have an account?
Ashok0572
batch class to update field in parent object when child object field date__c >= today().
Here Parent object is Account,and child object is Certification__c,and the field to be updated in Parent object is Rating
Good Day!
Please find the sample code below:
global class BatchUpdateAccount implements Database.Batchable<sobject>{
global string query;
global database.querylocator start(Database.BatchableContext BC){
query = 'select Id,name from Account where Id in (select Account from Certification__c where date__c >= today)';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope){
List<Account> cons = new List<Account>();
forAccount s : scope){
s.fieldname='assign the value';
cons.add(s);
}
update cons;
}
global void finish(Database.BatchableContext BC){
}
}
To execute from developer console
BatchUpdateAccount b = new BatchUpdateAccount();
database.executeBatch(b,100);
Mark this as best answer if this answers your query.
Regards
Sampath Kumar Goud