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)

3
votes
0answers
29 views

Best way to bulk update data in salesforce

We have created a trigger that generates some information for a column on the Opportunity object. We now want all 400,000 existing opportunities to have the same information. The logic is encapsulated ...
2
votes
1answer
29 views

Are static variables reset per batch during bulk DML operation? (Executing triggers for field updates)

A while back I had a trigger issue where I needed a trigger operation to execute exclusively on the second update or an update after an insert. So I had some code like this: Trigger Handler Class ...
1
vote
1answer
25 views

How does the batch execution fetch records to do any operations

Okay, I have huge set of records in a Custom object and i'm fetching these to do some kind of DML operations. During this batch process, how exactly does the records are fetched as in what order and ...
0
votes
2answers
36 views

Batch Class CallOutLimit Doubt

As we have 10 callout governor Limit in each execution . So I can query 100 records in start and execute the batch class with batch size as 1 and do 10 callout for each record . So total I can query ...
1
vote
3answers
90 views

Batch Class shoudnt go to execute on certain condition

I have a logic in which sometimes I dont need to execute a batch class execute method. How to achieve this as we cannot pass null or whitespace in query locator
1
vote
0answers
34 views

Add/Remove Campaign Members Based on Contact List using Apex

I'm having a hard time figuring out the logic for this in Apex. In C# I would just use linq. I have an existing campaign that I want to add/remove members based on new lists of contacts. Basically, ...
0
votes
2answers
65 views

Apex CPU Time limit exceeded error

I have a batch apex class that is facing CPU time limit exceeded error. Can someone please help me to by pass this error here? Please find my batch apex here. global class Account_chk_batch ...
0
votes
1answer
31 views

Apex Batch: Query locator failure

I am facing an issue with the querylocator line here. My code snippet as below. global Database.QueryLocator start(Database.BatchableContext BC){ query = 'select Id,(select Name from ...
0
votes
0answers
16 views

Creating a class object in a method in different class and returning the object

How to create a class object in different class's method and return its object. The class is a batchClass whose object needs to be created and returned in different class. My code so far: public ...
0
votes
1answer
34 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
23 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
27 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
40 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
59 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
57 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
59 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
138 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
22 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
28 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
59 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
41 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
41 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
60 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
59 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
78 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
68 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
18 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
53 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
67 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
51 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
126 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
77 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
67 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
150 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
81 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
62 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
42 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
67 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
51 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 ...
1
vote
1answer
90 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
52 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
67 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
38 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
61 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
155 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
124 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
167 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 ...
2
votes
1answer
775 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 = ...
1
vote
0answers
131 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 ...