You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
Batch apex is not updating values
Hi,
I wrote a batch apex to update custom field in account for some reasons its not working please suggest me what is the issue in this batch apex
I wrote a batch apex to update custom field in account for some reasons its not working please suggest me what is the issue in this batch apex
global class batchAccountUpdate implements Database.Batchable<sObject> { public List<Account> parentIds = [SELECT id FROM account where parentid = '']; public List<Account> results = [SELECT id FROM account WHERE parentid IN :parentIds]; public List<aggregateResult> minopp = [SELECT id,accountid,min(closedate) closedates from opportunity where accountid in (SELECT id FROM account where parentid = '' ) group by id,accountid ]; global Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator([SELECT id FROM account WHERE parentid IN :parentIds]); } global void execute(Database.BatchableContext BC, List<Account> scope) { for (AggregateResult ar : minopp ) { for(Account act : scope) { act.Logo_Since__c = Date.Valueof(ar.get('closedates')); update act; } update scope; } } global void finish(Database.BatchableContext BC) { } }
Thanks
Sudhir
Thanks
Sudhir
you was updating value that was not selected in scope query. I am potinting out to field Logo_Since__c.
Please past here your last batch class.
Thank you
Peter