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
2answers
32 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
0answers
25 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
23 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
66 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 ...
6
votes
0answers
43 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
47 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
111 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
66 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
38 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
18 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
50 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
30 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
33 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
35 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
54 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
35 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 ...
2
votes
0answers
42 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
63 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
82 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
115 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
189 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
46 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
56 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
38 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
32 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
99 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
93 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
31 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
23 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
164 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
107 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 ...
6
votes
1answer
81 views

keeping a running count (rollup) with batch apex

Is it possible to keep a running count of all tasks by whoId in batch apex? I want to aggregate all tasks for a contact, but how do you prevent the count from resetting after each batch? global ...
1
vote
1answer
49 views

Asynchronous Calls: Order Of Execution In A Test Method

Imagine the following scenario: Trigger myTrigger on User calls a future method which flags Account records. Then a Batch Job must run to process the records. While testing, I am first inserting ...
1
vote
2answers
42 views

Batch Apex Class To Move One Account Opportunities and Cases To Another Account

Now I have 2 Accounts, Suppose Say Account1 and Account2 .Account1 is having 2 opporotunities and 3 cases Now I want to reparent all these opportunities and cases to account2 using BatchApex. Thanks ...
1
vote
1answer
46 views

Batch Apex to update Opportunities if the stage is closed Won

I'm want to update all Closed Won Opportunities Every Month and this is my batch apex class the problem here is it's not entering if loop but I guess if loop is proper. I'm unable to rectify where the ...
0
votes
0answers
88 views

Unit test error: INVALID_FIELD_WHEN_USING_TEMPLATE

I'm sending emails to internal users from a batch job using SingleEmailMessage. When I run the batch job everything processes correctly and the emails are sent correctly. I'm using two different ...
0
votes
1answer
73 views

send email to users from a batch job

I have a batch process that is sending emails to Users. Is there a limit on the number of emails that I can send to users thru a batch process? Here is my batch code: global class ...
7
votes
2answers
60 views

What does the Batch Apex “Holding” status mean and where is it documented?

I've seen the following values in the AsyncApexJob table during the 'cradle to grave' life cycle of a Batch Apex job: BEFORE running: Queued Preparing WHILE running: Processing AFTER running: ...
1
vote
1answer
80 views

Insert Account Contact roles?

Actually we have a requirement to perform one contact with multiple Accounts scenario. To perform this logic I have a custom object called "Data Feed".We upload the data in that Data feed object ...
0
votes
1answer
99 views

Batch Apex and Lists

I have batch class that I'm using to add Contacts to a Campaign. I could have up to 6000 contacts I need to add at one time. I'm calling the batch from another controller class. Question is for ...
1
vote
1answer
73 views

Unable to iterate database.saveresult list

I am doing an insert using Database.Insert in a batch class, the code is as below Database.SaveResult[] srList = Database.insert(clonedList, false); for (integer i=0; i<srList.size(); i++) { ...
0
votes
1answer
46 views

Apex batch for rest calls

In my controller I have a wrapper class that gets some of its fields from case object and some from rest calls. String query = 'some query'; List<Case> cases = Database.query(query); for(Case ...
2
votes
2answers
37 views

database.Stateful Interface is not working as expected

global class batchForStateful implements Database.Batchable<Sobject>,Database.Stateful{ global static list<cust__c> soList=new list<cust__c>(); global database.querylocator ...
3
votes
1answer
139 views

Scheduling Batch class

How to schedule the batch for every two hours per day? I try like this String schedule = '0 0 1/2 * * ?'; System.schedule('Jobname',schedule,new SampleTracking()); but i don't know it ...
3
votes
3answers
79 views

Transaction Control for multiple batches

Is it possible to implement transactional DML for batches? for example we have parent object and child and if the update of child object is failed then the update of this particular parnet and child ...
3
votes
2answers
256 views

custom error logging, batch apex, failure/success counts

This may be simple, but I want to implement custom error logging for a batch class, where handled exceptions get written to a logging object in the database. So I could use the technique in Andrew's ...
2
votes
0answers
38 views

Apex batch does not update scope

I just created a batch that set some null values in some fields, what I notice is that the batch sets the nulls but it does not update the Object. I need to Edit and Save in order to see the new ...
4
votes
1answer
37 views

Notification from timed-out batch query?

I have a batch process where it's intermittently failing due to what looks like the batch query timing out (details are here if you're interested). The error ends up looking like this in my log. ...
7
votes
2answers
127 views

Measuring performance of batch apex query

Is there a good way to tell how long the query in a batch apex job is taking? I don't find anything in the debug logs. I can see each batch and how long it takes, but not how long the initial query ...
1
vote
0answers
80 views

Unable to get any results from query using database.queryLocator

Below is the query string I used for an apex batch job and when it gets query through the Database.QuaryLocator start() method, it doesn't return any results when I execute anonymous. I have test data ...