You need to sign in to do that
Don't have an account?
raj jordan
batch class to update account related opportunities
Hi all,
when account have some related opprtunities i want to update opportunity field when account is updated it should get updated for one related opportunity or more than one using batch class
Can you help me through this
Thanks in Advance
Jordan
when account have some related opprtunities i want to update opportunity field when account is updated it should get updated for one related opportunity or more than one using batch class
Can you help me through this
Thanks in Advance
Jordan
Just Call Database.executeBatch(new BatchOppUpdate(contactsToUpdate)); in Trigger on update event then define a batch class as follows:-
global class BatchOppUpdate implements Database.Batchable<sObject>{
List<Account> parentAccount = new List<Account>();
List<Opportunity> Opplist1 = new List<Opportunity>();
global BatchOppUpdate(List<Account> AccountUpdate) {
parentAccount = AccountUpdate;
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return DataBase.getQueryLocator([SELECT Id, AccountID FROM Opportunity WHERE AccountID IN :parentAccount ]);
}
global void execute(Database.BatchableContext BC , List <Opportunity> Opplist) {
for (Account acct : mapAccount){
for (Opportunity opp : contactList){
if (opp.AccountID == acct.Id){
Opplist1.add(new Opportunity( Id = opp.Id, );
}
}
}
update Opplist1;
}
global void finish(Database.BatchableContext BC){
}
}
If It really helps you please give it as best answere :)