Classes implementing the `batchable` interface are used when there is a need to operate on a large number of data records which would normally be problematic due to the imposed governor limits.

learn more… | top users | synonyms (1)

0
votes
1answer
31 views

Apex error: Initial term of field expression must be a concrete SObject

I have to update bulk records by apex class which is called from an apex trigger. Please find my class and trigger below. Batch class: global class UpdateAccountArea implements ...
4
votes
0answers
22 views

Can batchable custom iterables support null values?

Background We're trying to do a type of pseudo-parallel processing mechanism, where a record will be processed twice. The thought was to make an overlapping series of values that look like this: ...
1
vote
1answer
26 views

Code efficiency help: Can't avoid CPU limit (even with batch)

I'm at my wits end guys. I've rewritten my code a half dozen times now. First I though I could increase efficiency with my loops and if clauses, then I started incorporating tips I read using maps ...
0
votes
2answers
39 views

SOQL Query for month operator

I have to compare month value of a custom object's date field, if it is of the current month. Please find the piece of code below. I am getting error here. Can someone help me? Code piece: ...
6
votes
2answers
50 views

Is it possible for Database.executeBatch() to execute before the parent transaction is committed?

Previously, I would have assumed definitely not, but we recently ran into an issue where we have a large transaction (via VF page) which inserts a ton of rows under a parent object. Then it calls ...
3
votes
1answer
27 views

Future method cannot be called from a future or batch method, Case Trigger with Salesforce for Social

I get the following inside a Case Trigger when I try to call a future method: System.AsyncException: Future method cannot be called from a future or batch method So far this exception ONLY occurs ...
2
votes
1answer
58 views

Too many dml rows exception

I tried to insert records for call__c object which gives this exception Trigger: trigger trgInsertCall on Call__c (after insert) { Set<Id> clientIds = new Set<Id>(); ...
0
votes
2answers
82 views

Too many DML rows: 10001

I have a trigger which performs an insert operation.One record count is more than 10k.So,Its giving this exception.I have tried batch apex and future method.Its is not working.Any help will be ...
1
vote
1answer
18 views

Join Query to a Batch Handler and processing the result rows

Can we write a join query and pass on to a batch handler. Once I get all the rows, I want to dynamically fetch values using their fields described from the rows containing info of both the objects. ...
1
vote
1answer
24 views

How can I query the class which the schedule job will call

I am trying to get the name of the schedule / batch classes called by the schedule job Trying this select Id,CronJobDetailId,CronJobDetail.Name, ...
2
votes
1answer
58 views

Execute method is not getting called

I have called a batch class from a trigger.In debug log start method is getting called.But execute is not getting called. trigger: trigger trgInsertRecord on Custom_object__c(after insert,after ...
4
votes
3answers
39 views

Batch Execution Exception when run in sequence

I am getting the below exception when I am running batches in sequence. That is, I am calling another method to create next batch once the first batch is in it's finish method. Database.executeBatch ...
1
vote
1answer
33 views

Test class for Batch class with web service callout and test data

I have a batch class which in turn makes REST callouts(No future annotation). Now I want to write test class for same. Currently what i tried - -StaticResourceCalloutMock class in salesforce - ...
4
votes
1answer
45 views

Find Apex batch status programmatically

I have a batch class, I need to email and run another batch in the 'Finish' method of batch ONLY IF the batch ran successfully. I would like to have batch status in the finish method (like the batch ...
0
votes
0answers
20 views

Callout Limits within Batch Apex [duplicate]

How to use the batch to send more than 10 emails using callout. I've done a class batch that contains a start that has the query, an execute that has the sendEmail and a finish that has nothing but ...
3
votes
2answers
47 views

How do you use Batch for send more than 10 emails?

I have been watching how to implement the batch for sending more than 10 email but I get errors. When I send emails I have a limit 5 and also are sent several times to the same user email global ...
4
votes
2answers
64 views

Batch Apex: Can I run code prior to running 'Execute' code on batches, and will it affect governors limits?

Below is my question in a nutshell, using the framework for a batch apex class: global class ActOn_Batchable implements Database.Batchable<sObject>{ string query = 'query here'; **CAN ...
1
vote
1answer
61 views

How can I make my trigger only fire after all (of several thousand) records are finished being inserted?

I have a batch apex class that I need to fire only after all of the thousands of records from a record import have been inserted into a custom object. I thought I should use a trigger to fire my ...
0
votes
0answers
17 views

System.CalloutException: public-proxy20-0-chi.data.sfdc.net

Never seen this error before. It's occurring sporadically when calling an asynchronous call from a Batch. This code has been executing without this issue for years on the same scheduled job. Seems ...
0
votes
2answers
46 views

Apex batch getting an error out

I have this Apex batch having issues with call. I am new in this apex-world. Can someone help me out. My code is here. global class Samplelotinactive implements ...
1
vote
1answer
64 views

Tooling API and Scheduled Batch Apex - How to access

Without storing a users credentials to salesforce how can one access the tooling API during a daily scheduled batch? Currently we are storing the users username and password in encrypted fields but ...
3
votes
1answer
41 views

Batchable class variable shows as NULL in finish() method

Sorry if the format is not good, first post ever and I don't know what all the options are. totalRecords list size is printing as NULL in the email message body, I cannot figure out why. global ...
4
votes
2answers
106 views

Apex CPU Time limit in Batch start() - is this a Query Timeout and how to cope with?

I have a Batch iterating over a large amount of records (with many fields) and 2 of their related child records. The start() method uses Dynamic SOQL to fetch them via QueryLocator to vary which ...
7
votes
0answers
67 views

An interface extending a system interface causes process hangs?

We're trying to implement dynamic batch processes to dispatch different classes. Specifically, we have integrated multiple systems, and depending on certain events, we dispatch callouts to those ...
2
votes
2answers
65 views

Testing time-based batch class

I have a batch process that closes cases after 30 days of inactivity. Is it possible to write test code that would create a case that is over 30 days old?
2
votes
1answer
135 views

Is using Database.executeBatch from a trigger an anti-pattern?

In a managed package we have a trigger on Account that propagates a custom field status value from the Account to a large number of related custom objects and wrote the logic in a batchable to avoid ...
4
votes
1answer
78 views

Sandbox batch execution takes too long to be completed(simple task)

Is it true that running a batch class in Sandbox with incredibly simple task takes too long than Production? I've tried @future with the same task and it process my Streaming API immediately. ...
0
votes
2answers
55 views

I can't execute a simple batch class in my controller

I was about to use a batch class and now I'm stuck cause It wont execute. I don't know why. Here's the code from my controller class: public ConstructorName(){ dispForecastSummary(); } public ...
1
vote
0answers
24 views

Making apex callout after sendEmail() in Batch apex

This is related to question, Processing callouts from Batch, but is specific to Emails operations. We are sending contents of email in apex callouts. The content contain merge fields, which is not ...
3
votes
3answers
58 views

How to estimate how long a given batch will run?

Are there any reliable numbers, heuristics, experience reports to estimate (and display it to the triggering user) how long a given batch will run? Sure the time will mainly depend on the number of ...
2
votes
1answer
41 views

System.LimitException: Too many async jobs enqueued for this apex test context

I'm trying to run with a unit test a batch apex process where I'm calling the same class 5 times. For example: public class MyBatch implements Database.Batchable<SObject> { ... public ...
0
votes
1answer
62 views

Help with Aggregate Result in Batch Apex

I received some help with this on the Salesforce forums but I can't get over the hump and get it working. The code below saves fine and I'm able to schedule it and it runs through all of the batches. ...
2
votes
1answer
46 views

Can a DML retry solve UNABLE_TO_LOCK_ROW race conditions?

I have 2 Batch classes working on different child objects of a common master object. Batch Batches are started parallel to speed up this long running cleansing operation. It depends on the underlying ...
3
votes
2answers
61 views

Date literals not working in batch apex?

SOQL: [SELECT Id,Name FROM Account WHERE createddate=THIS_MONTH] This query is working fine when it is called from button, but it is unable to filter according to the created date when it is ...
1
vote
1answer
36 views

Execute global batch job from installed package

How to execute global batch job from installed package: NS__BirthdayBatch bb = new NS__BirthdayBatch(); Database.executeBatch(vb); When I try ti run this code in dev console or workbench I am ...
3
votes
0answers
55 views

@future and triggers

I want to do a bulk update of records in parallel, but Batch Apex doesn't permit this. I was wondering if the following solution would work: I have an SObject defined that holds a value for the ...
0
votes
2answers
113 views

Error while inserting records using batch apex

I want to insert Account records using batch apex and below is my code . I'm getting following error shown in dev console 5:50:40:090 EXCEPTION_THROWN [18]|System.DmlException: Insert failed. ...
0
votes
1answer
108 views

Error Attempt to de-reference a null object

My requirement is to get the list of territories present in an Account_Territory_Loader_vod__c object for a particular account and check that combination of account and territory whether it is present ...
5
votes
2answers
139 views

Does Batch Apex fire off triggers?

For example, If I have a bunch triggers that aren't bulkified, so I'll end up hitting the governing limits were to do 100 insert opportunities in an separate apex class. For batch apex, if I were to ...
1
vote
1answer
560 views

You have uncommitted work pending. Please commit or rollback before calling out

i have written a future method here is source code @future(callout=true) public static void futureDownloadAttachment(Set<ID> documentsID){ List<SpringCM_Attachment__c> logs = ...
0
votes
0answers
93 views

I am executing a Batch Apex class to delete the records from Recycle Bin but the records are not getting delete?

This is my code: global class EmptyRecycleBin implements Database.Batchable<sObject>{ global Database.querylocator start(Database.BatchableContext BC){ string query ; return ...
1
vote
1answer
68 views

Max of Limited Query SOQL

I am trying to batch by date for large tables. I want to create batches of ~50000 records ordered by the LastModifiedDate. What I need is the MIN(LastModifiedDate) and MAX(LastModifiedDate) for each ...
0
votes
1answer
53 views

Apex job completed but total batches are zero

Here i have issue regarding Apex Job.i have completed the Apex batch job but total batches are 0. Should I be concerned here why that the batch controller is showing “0” here? here is the ...
4
votes
1answer
34 views

How to do testing in a Batch-intense app?

I have an app with a quite complex data model and many asynch batch jobs triggered by DML operations on many of my custom objects. As in Apex Test you can only synchronize a single asynch operation ...
2
votes
1answer
145 views

Batch class query and scope are not same

I have a date field (in my below code it has api name Payment_Follow_Up_Date__c) on Opportunity. With the use of Schedulable and batachable interface I am trying to send sms to client as a reminder. I ...
4
votes
1answer
110 views

Variables in Batch Apex

I'm reworking some batch Apex in my org and am having some issues accessing class level variables. An example of what I have is: global class myBatchClass implements database.batchable<sObject> ...
1
vote
2answers
34 views

batch apex to associate a contact to a case

I am using batch apex to associate a contact to a case. I will need to compare all the contacts in the system to the cases with a 'new' status. first_name__c and last_name__c are fields on the case. I ...
0
votes
1answer
24 views

Can I run Batch code so each Iteration of the Batch has its own Execution Context for an API call?

I have have a list of formats of a file I need to download via API from a 3rd party service. List<String> FileFormatList = new List<String>{a1s, ...
2
votes
1answer
290 views

Batch Apex: Too many query rows: 50001 error

I have a batch program that is using database stateful to do some rollups across all activities associated to contacts. The total number of batches is 6,771 and the batch size is 200. The program ...
5
votes
1answer
130 views

Does Test.stopTest() ensure a System.Schedule/Database.Batchable completes in a test?

I am struggling to successfully test some code that is essentially the same as the code here Apex test class for schedulable class that checks for 5 batches running already. I can get the ...