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
Patrick BulaczPatrick Bulacz 

Batch Apex Issues

Hi All,

 

Getting quite frustrated with trying to find a solution for this issue.

 

Using Batch Apex and it is intermittently working correctly.

 

I have raised a case #03007660 ... however lucky me has had it assigned to someone out of office (that's the email reply I got anyway).

 

See my code below.

 

I have tried and tested it with batches of up to 327 records and it has worked successfully. However now trying to test with larger batches of >3000 records all I get is a debug log that says see below. And my Apex Jobs log just says..

 

Job Type = Batch Apex

Status = Completed

Total Batches = 0

Batches Processed = 0

Failures = 0

 

Essentially nothing happens. No error no real message nothing. Any help would be much appreciated here, I've seen a few other posts with similar issues, however this is getting critical for me to find a solution! 

 

I have also tried 'chunking' the batches at varying intervals all the way from 25 - 200 in the 'execute' method, without any success and also as another post suggested added a 'limit' to my query which also didn't help.

 

SOQL locator query with 3324 rows finished in 608 msCumulative resource usage:Total email recipients queued to be sent : 0Stack frame variables and sizes:  Frame0

 

global class PaymentCreate implements Database.Batchable<SObject>{// Creates and Processes Payments
public date PSBD;
public String PSID;
public String PSM;
Public String query;
global database.querylocator start(Database.BatchableContext BC){
  return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, Sobject[] scope){
  List<AcctPayments__c> PaymentHolder = new List<AcctPayments__c>();
  List<Recurring_Payment__c> batchRP = new List<Recurring_Payment__c>();
  for(sobject s : scope){
    Recurring_Payment__c p = (Recurring_Payment__c)s;
    PaymentHolder.add(new AcctPayments__c(Payment_Session__c = PSID, Contact__c = p._Contact__c, Payment_Total__c = p.Recurring_Amount__c, Auto_Allocate__c = true, Payment_Method__c = PSM, RP_ID__c = p.Id, RP__c = p.Id, Recurring_Payment_Processed__c = true));
    p.MEMforce__Last_Processed__c = PSBD;
    batchRP.add(p);
  }
  insert PaymentHolder;
  update batchRP;
}

global void finish(Database.BatchableContext BC){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setReplyTo('batch@batch.com.au');
mail.setTargetObjectId(UserInfo.getUserId());
mail.setSaveAsActivity(false);
mail.setSenderDisplayName('Batch Processing - Payments Updated (Loaded and Processed)');
mail.setSubject('Batch Process Completed - Payments Updated (Loaded and Processed)');
mail.setPlainTextBody('Batch Process has completed - Payment Updated (Loaded and Processed)');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
 //INVOKE
     loading.query= myQuery;     loading.PSID = thisPS.Id;
     loading.PSBD= thisPS.Banking_Date__c;
     loading.PSM = thisPS.Payment_Method__c;
     ID batchprocessid = Database.executeBatch(loading, 50);
Message Edited by Patrick Bulacz on 10-15-2009 09:36 PM
luckymeluckyme
It works fine for me - I tested up to 3000 records. Also, you can use (implement) Database.Stateful to make your batch stateful.
CodeStreetDevCodeStreetDev
I am having this exact same issue. Is there any solution / explanation of this? 
pbulaczpbulacz

It looks like it's an org specific problem as other have tried my code with success so I've just had to keep following up on the case.

 

Most others I find with the same problem have had to do the same raise a case and follow it through.

 

There is a good post here by tmatthiesen about some known batch apex issues but no solution, just a point about queryLocator construction, which could well be it but doesn't explain why it works in some orgs and not others.

 

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=21475