Questions tagged [batch]

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.

389 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11 votes
1 answer
1k views

Total Batches increase during the run of a batch (again)

I experienced a batch that changed (increased) the #TotalBatches during its execution. 104 total batches Reload. 106 total batches I experienced this year ago (see this question Total number of ...
Robert Sösemann's user avatar
10 votes
1 answer
191 views

Non-Selective Query Async (fails) vs Sync (works) - Is that supposed to happen?

Running into the following issue only during async processes (i.e. Batch Apex): Code used is same for both sync and async apex. Both essentially pass a single record into the method Batch scope is 1 ...
Eric's user avatar
  • 54.2k
8 votes
0 answers
1k views

Append content to a document

I need to create a huge document. Naturally I face up the apex's limits such that heap size and string length. I can split the creation of the document using a batch job. I thought to create the rows ...
lastYorsh's user avatar
  • 331
8 votes
1 answer
3k views

error from test method - "apex job is already scheduled for execution"

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
apn's user avatar
  • 1,722
6 votes
0 answers
262 views

How many child records can a parent cascade delete (documented limit)?

I have a CustomObject__c which has childrens 2 level deep. Together a single parent object can have many 10.000 child records. Would it work to auto-delete the thousands ob child records just using a ...
Robert Sösemann's user avatar
5 votes
0 answers
118 views

Stress-test and prove limit-scalability of Asynchronous code

Giving my question a proper title was hard as I am only partially sure what I am actually looking for - solution-wise. In our fully native (no AWS or Functions backend) Managed Package many ...
Robert Sösemann's user avatar
5 votes
0 answers
70 views

Does 'Deploy with Active Jobs' work for managed packages?

So there's this new feature: 'Deploy with Active Jobs' It lets you deploy batches and schedules even if they're running. This is great for changesets. Does it work with managed packages?
Matt and Neil's user avatar
4 votes
0 answers
1k views

AsyncApexExecutions Limit exceeded different errors

We have a batch that is running queueable inside batch execute. And we are testing this framework with volume data to know its limits. To give an example, if I test it using 1000 records with 1 scope ...
love gupta's user avatar
4 votes
0 answers
499 views

Can we work around Owner related fields not being retrievable via SOQL in apex tests?

Background: Recently I wrote a very simple Batch to run on the 1st of every month. Its purpose is to query for any Project__c records that aren't Complete, and create a related "Carry-Over" record in ...
Morgan Marchese's user avatar
4 votes
0 answers
327 views

Why does BatchableContext.getChildJobId() return null inside Database.Batchable.execute()?

Per the docs, BatchableContext.getChildJobId() should return the id of the current batch chunk; when running in Database.Batchable.execute() I would expect that to always be populated. I'm using it ...
Jason Clark's user avatar
  • 11.9k
4 votes
0 answers
614 views

AsyncApexJob: TotalJobItems != JobItemsProcessed + NumberOfErrors

I'm running into an odd issue where AsyncApexJobs (from Batch Apex) are finishing with a status of "Complete" but the TotalJobItems != JobItemsProcessed + NumberOfErrors. Should I be concerned that ...
NSjonas's user avatar
  • 10.2k
4 votes
0 answers
110 views

mixed_dml on batch execution on unknown standard object

I'm running a batch that updates several custom objects. Sometimes I get a mixed_dml error but it's not something I can reproduce, It's an intermittent error. The message that is thrown is: ...
Marcos Carri's user avatar
4 votes
0 answers
840 views

Batch jobs sitting in "Holding" status after flex queue turned on

Since turning on the flex queue, I am seeing batch jobs that previously executed near-instantly now sitting in the "Holding" status for a very long time. It appears that only one job per hour (on the ...
jkraybill's user avatar
  • 11.2k
4 votes
0 answers
139 views

Batch Apex: Invalid field StageName for OpportunityHistory

In my SalesForce managed package I have a Batch Apex job that queries OpportunityHistory and does some post-processing (basically serialize them and posts to external Web Service) When I schedule and ...
Sergio Kozlov's user avatar
4 votes
0 answers
61 views

Will (Minor) Push upgrades conflict with running batches?

What will happing to running Apex Batch jobs when I perform a Push (Minor) Upgrade (Patch) into a customer org? Is that save to do? Under which circumstances? I could not find documentation or any ...
Robert Sösemann's user avatar
3 votes
0 answers
329 views

Tasks with TaskRelations not showing up in SOQL query results

I have written a batch which stamps the first activity date on contact records with the first created date of task or event on that record. My SOQL query is excluding tasks with Allow Users to ...
Shiva Achukatla's user avatar
3 votes
0 answers
139 views

Scheduler test class fails while packaging

Scheduler Class: global with sharing class Demo_Scheduler implements Schedulable { global void execute(SchedulableContext sc) { Database.executeBatch( new Demo_Batch(new List&...
d_k's user avatar
  • 1,291
3 votes
0 answers
111 views

Execute Method in Batchable Class does not execute on all records returned in Start method Querylocator

I am seeing a very similar issue to the one discussed in this question, which was due to a bug in Spring '17. The Querylocator returned by the Start method returns 9,989 records, which I can verify ...
kenslewis's user avatar
  • 328
3 votes
0 answers
1k views

Why doesn't Dataloader use specified 10k batch size when Bulk API is selected?

I have this sample CSV file containing 10,000 records (with 33 columns) I'd like to import it via Dataloader into Case object at my sandbox environment. I tried using these settings below with Bulk-...
compski's user avatar
  • 1,352
3 votes
0 answers
4k views

INSUFFICIENT_ACCESS_OR_READONLY error when sending email from scheduled class

I have a batch job that send emails on user anniversaries. It works when I run it in the execute anonymous window from SF's developer window. I'm sending it through the org-wide email address and I've ...
slim's user avatar
  • 107
3 votes
1 answer
2k views

Webservice callout - Test class - not working

I have batch class that makes a HTTP callout to a remote web service. To deploy into production, I have created a test class with StaticResourceCalloutMock. I am executing the test class in a full ...
Razu's user avatar
  • 353
3 votes
0 answers
809 views

Future callouts when trigger fires from batch job

I have a batch job that goes through a list of a custom objects and updates certain field. This is working correctly. The custom object is part of a managed packaged. On the custom object is a ...
Paul's user avatar
  • 31
3 votes
0 answers
896 views

Queueable interface to chain Apex batch jobs

Can we use the Apex Queueable interface to chain batch jobs? I am planning to invoke a Apex Queueable interface from the finish method of a batch job. The Queueable interface would queue the Apex ...
nonce's user avatar
  • 85
3 votes
0 answers
2k 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 ...
Helephant's user avatar
  • 313
3 votes
0 answers
358 views

Why does this Batch always and only abort in Production?

I have a long running asynchronous process that process millons of records in a CustomObject__c. To prevent other limits we have split this into 2 Batch classes that work on this table in parallel. So ...
Robert Sösemann's user avatar
2 votes
0 answers
83 views

Apex Engine old Version of apex code changed?

Recently (since January) we have encountered some cases when deploying new versions of our managed package. We have had at least 2 separate instances where changing a batch or an apex class referenced ...
Jose's user avatar
  • 2,142
2 votes
2 answers
417 views

Batch Class Error: Start did not return a valid iterable object

I have a simple piece of batch code that iterates over all Location__c records that don't already have Folders. It then calls a method to create the missing folders. public with sharing class ...
Kevin's user avatar
  • 21
2 votes
0 answers
453 views

Iterable in apex batch start

Iterable had an upper limit of 10000 records in batch apex earlier, when used as return type for start method. However in docs, I cant seem to find it anymore. Is this limit removed or not relevant? ...
Amit's user avatar
  • 344
2 votes
0 answers
478 views

How to interpret bulk API processing times

According to the docs apexProcessingTime is The number of milliseconds taken to process triggers and other processes related to the job data apiActiveProcessingTime is The number of milliseconds ...
Dwarakesh Pallagolla's user avatar
2 votes
0 answers
53 views

Batchable Apex: Querying records that follow 2 sets of criteria in start and then doing 2 separate things with each set of records in execute

I'm writing a batch job that queries for Contact records following 2 sets of criteria and then adds them to an export object with corresponding flags of whether they fulfilled criteria set 1 or 2. My ...
sFishman's user avatar
2 votes
1 answer
87 views

Prevent limits in a callout intensive process where client can only receive one request at a time?

I have a callout intensive process where the client can only receive one request at a time and I'm having a hard time identifying what is the best practice for asynchronous solutions to handle this ...
S.B.'s user avatar
  • 2,071
2 votes
0 answers
185 views

order of records received in batches for batch class

I have a batch class where i need to grab the records sequentially. It looks like if i am querying regularly in salesforce and system.debugging the outputs, the records do not seem to be in any ...
Tim Willis's user avatar
2 votes
0 answers
783 views

How can I work with both QueryLocator and List<SObject> in a single batch class (not a single instance)?

I've been working on a chainable batch class. The constructor can take in either a service & query or a service & list of records. In almost all cases, the service/query are passed in. In ...
myrddincat's user avatar
2 votes
0 answers
789 views

"LimitException: Batchable instance is too big" when scheduled batch runs at night

Note: This is not a duplicate of the other similar questions. We checked them before. So please don't close this as a duplicate! When calling this batch class in a production org: global class ...
Robert Sösemann's user avatar
2 votes
1 answer
63 views

Source of an erroneous "You have uncommitted work pending" error in Test?

From the top, I do understand how "You have uncommitted work pending" errors happen, but the following is very strange behaviour from Salesforce... It seems that for one org we have, creating an ...
Aidan's user avatar
  • 13.7k
2 votes
0 answers
162 views

Apex Batch Test - works if I populate only one account, fails in setup with 2 accounts

I have written my first Apex batch processing class. It works when I manually create records and run it in my sandbox. It is very simple. We've added a set of fields that can have up to 3 values: '...
Rob Mackie's user avatar
2 votes
1 answer
1k views

Unable to insert records using Iterable Batch class

I'm trying to create an Iterable Batch class for inserting records. I'm able to insert my records in my normal class. I have created the Batch class and am trying to call it my current class in the ...
Sneha Jagtap's user avatar
2 votes
1 answer
578 views

Getting Encoded Vertical Line ("|") character when querying in Batch Class

I have created a text field SP_Login_Name__c on user in which i am saving the sharepoint login name which i have to use for some further api requests. Sharepoint login name is saved in the following ...
Shubham Sharma's user avatar
2 votes
0 answers
388 views

Manually aborting a job in a test class

For the purpose of testing some code, I want to be able to simulate a batch job run and abort in the middle of execution. How can I do this from an apex test? I tried using a boolean flag to abort ...
coldspeed's user avatar
  • 701
2 votes
0 answers
117 views

Unlock parent, then update child, then again lock back the parent

I have a batch class that is used to update a Field1 of Obj1. Obj1 is child of Obj11. Inorder to update Obj1, I need to unlock its parent Obj11 first. [by updating lock__c=false]. Then update ...
user59759's user avatar
  • 581
2 votes
1 answer
98 views

SOQL Limit Hit - Aggregrate

My query hit the 50,000 record limit. Can someone help me rework the query so it operates within the limits. For reference, we have one account that has 92,000 active employees. The aggregate ...
Matt M's user avatar
  • 1,477
2 votes
1 answer
600 views

Testing Batch Class that triggers Chatter Post

I have a batch class that needs a test class. In creating the test records, the insertion of a necessary object record triggers a Chatter Post via another trigger. That chatter post references a ...
sfdcJameson's user avatar
  • 1,067
2 votes
1 answer
736 views

Rollback complete batch process

I want to roll back a complete batch related transaction if there is any exception while processing anywhere during batch execution I can roll back that specific transaction, but not sure if I can ...
SEuser's user avatar
  • 1,855
2 votes
0 answers
634 views

Get first row of CSV data in salesforce and use for mapping

I want to get data from csv and upload it to salesforce. I use this link http://www.blueengine.com.au/?p=40#comment-271 and http://developer.financialforce.com/customizations/importing-large-csv-...
Hope's user avatar
  • 1,263
2 votes
0 answers
2k views

INVALID_CROSS_REFERENCE_KEY, invalid cross reference id on Lead update

I am trying to run a batch apex to update a list of leads, i get this error 'INVALID_CROSS_REFERENCE_KEY, invalid cross reference id:' only for few of the apex jobs, the other jobs of the batch ...
SF Learner's user avatar
  • 1,037
2 votes
0 answers
47 views

How can I run batch apex inside of batch apex?

Here's the requirement: Rolls up the number of cases created within the last 30 days to the Account. global class ZW_BatchCaseNumberRollup implements Database.Batchable<sObject>,Database....
sfdcnoob's user avatar
  • 1,097
2 votes
0 answers
1k views

Finish method in batch job not invoked after an exception is thrown and caught

I'm using Database.update in my batch class. This is wrapped around by a try/catch block. When I run the batch job some error occurs which is caught as I'm throwing a custom exception and catching it. ...
Shankar Anand's user avatar
2 votes
2 answers
544 views

Performance impact of relationship queries in batch start

For a new batch process I have a choice between immediately selecting relevant records in the start function (but using several [field]__r comparisons as they are junction objects being queried) or ...
Valyrion's user avatar
  • 1,144
2 votes
0 answers
1k 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 ...
Carlos's user avatar
  • 1,871
2 votes
0 answers
1k views

I want to insert, update and second time when I run Batch Class it should not add inserted records

I want to sync all Users record with Contact. I have only one Account where I want to sync all the User records. Now I am able to insert the records with Insert call of batch apex. But I am not able ...
Sachin's user avatar
  • 21

1
2 3 4 5
8