You need to sign in to do that
Don't have an account?
aj4
Message Edited by aj4 on 05-12-2008 04:56 PM
Apex trigger or Apex class for mass update on Account field at end of every Month
Hi!
In our implementation we have member field on account object. Every month we want to update this field with some value derived from child record.
1)Should we code Trigger OR Apex class to be call from S-control?
2)If it is trigger then how would you mass update all accounts?
3)Can we write Apex class and call it from s-control
4)Can you automate the process to run at the end of the month?
5) Please provide sample code for the solution for above.
Thanks
Message Edited by aj4 on 05-12-2008 04:56 PM
A trigger is nice, but it will work when child is modified no monthly
apex called from scontrol is fine, from a button or link
not a good idea, depending on how many accounts you may not be able to update all from a trigger.
Yes, examples in AJAX tools package on appexchange
5) Please provide sample code for the solution for above.
Thanks for the reply.
We have approximately 60000 accounts and still growing.
How will you handle data to hold so many record into list or set and proccess each account record to find child and then update account.
It will hit the governence limit because list cant handle for than 1000 record and dml limitation of 20.
Do you have sample code for such situation or solution.
Thanks
account [] accts = [select id from Account ];
for (account a : accts ) {
Pop__c [] pops = [Select Mem__c From Pop__c where Account__c =:a.id ];
double tot = 0;
for(Pop__c pop : pops){
tot = tot+ pop.Mem__c;
}
a.mbr = tot;
system.debug('account name '+ a.id+ 'tot '+);
update a;
}
If you find anything else on this please let me know.