function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Susan Love 2Susan Love 2 

batch processes

We have fields on our Account page which total number of meetings via the Contract page.  This is run through scheduled batches.  Unfortunately we noticed the Apex code was incorrect as one of the totals was wrong.  I have corrected the code but the existing totals that were there have not changed.  Would I need to put all the totals in as 0 then let the batches run to enable the correct totals to appear?
Prakash NawalePrakash Nawale
Hi Susan,
As per my understanding you can implement logicin in execute(scope) method of batch apex as
for(Account record : (List<Accont>)scope){
      record.totalNumberofMeetings = 0;
}

//Your code


Update scope;

Can you implement your logic this way or share you code so I can help you.

Regards,
Prakash
 
Abhishek BansalAbhishek Bansal
Hi Susan,

If your batch is processing all the records irrespective of any where condition then it should update all the totals correctly. It would be good if you can share your batch code.

Thanks,
Abhishek Bansal.
Susan Love 2Susan Love 2
There has been various bits of code written for this:

global class ScoreCardSchedule implements Schedulable {
     
    global void execute(SchedulableContext SC) {
        
        // Update the accounts with score card data
        ScoreCardBatch scb01 = new ScoreCardBatch();
        scb01.type = 'UpdateAccountsWithContractData';
        database.executebatch(scb01,100);

    // Update the RM users (owners) with score card data
        ScoreCardBatch scb02 = new ScoreCardBatch();
        scb02.type = 'UpdateRmUserAccountsWithContractData';
        database.executebatch(scb02,100);

 
Abhishek BansalAbhishek Bansal
Hi Susan,

We need to see the query that returns the records to be updated. If there is anything urgent on this then you can contact me on Gmail or Skype.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790

Thanks,
Abhishek Bansal.