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.

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Why is SerialBatchApexRangeChunkHandler more than the number of batches?

I am working on batch apex and I have just tried writing a simple code for learning purpose. In the start method I am querying the records limiting them to 7, and I am running the batch job from the ...
3
votes
3answers
58 views

Can a trigger with error ruin the batch it was fired from?

Consider I have a batch class which updates 50 records of Task. The batch class ran successfully and updated the Task records.Now the Task object has a trigger that runs on after/before update. Due ...
1
vote
0answers
27 views

'uncommitted work pending' callout exception thrown in *tests only*

I am converting a lead in the Execute method of a batch class, then making 2 callouts with those results in the Finish() method. It works gloriously and throws no errors. However, in the test ...
0
votes
0answers
27 views

Batch Class and SOQL Implications: 1% of the time a record gets updated that shouldn't

pretty high level question here based on some of the erroneous updates I'm seeing (less than 1% of total records processed). I'm currently running a batch class (50 record batch size). It is a ...
1
vote
1answer
41 views

How can I save a class when a batch job is running (without the Ant tool)

I am trying to figure out if we can save a class which is used in a batch job. I am unable to save a class. I can't save the class when a batch job is running. I don't want to abort the job. Is there ...
1
vote
1answer
33 views

Sending Inner class as a param from Queueable apex to a batch

I have a queueable apex that calls to a batch. Inside the queueable class - I have inner Class that writes a log with incorrect fields. The Inner Class inside the queueable class : public class ...
0
votes
1answer
33 views

getting error while using SendEmail in batch class

I'm trying to send email to list of users using batch class, but its throwing below error for few records. Error: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
6
votes
3answers
123 views

Database.Stateful does not work as expected when using instance variable of another class

We have private field service which is instance of HelperService. HelperService is pretty heavy class, that performs several callouts, transforms responses into Salesforce objects and logs errors ...
0
votes
1answer
44 views

How to iterate map inside a map

Hi I have a map which has a map inside a map as below Map<String,Map<String,String>> finaldataelementmap=New Map<String,Map<String,String>>(); Map<String,String> ...
1
vote
1answer
137 views

How to remove a SOQL query from a loop

I have a query for Opportunity records which are retrieved based on Account Id. I am not sure how I can remove them out of the for loop I had to use the Opportunity for each account in the list, ...
-2
votes
0answers
42 views

Facing 101 soql exception in case of testing batch class

I am facing error of 101 soql in case of running test class for batch class. Please find the batch class and test class as below: Batch Class: /******************************************************...
10
votes
1answer
343 views

Database.Stateful for a specific variable only

Is there anyway to maintain the state of a certain variable in Batch Apex across transactions. Database.Stateful will save the state for all the declared variables, Can i set it for only one specific ...
0
votes
1answer
43 views

Batch with 3 related objects

Suppose i have 3 related objects: Continent - Country - City. Country object is child object of Continent and City is child object of Country. City -> Country -> Continent. I would like make changes ...
1
vote
0answers
45 views

Optimised way to display batch job status on Visualforce page

In my Visualforce page, the user can schedule a job and after monitor the status of the job whether it is in progress or completed. Right now, I am querying AsyncApexJob table periodically to know ...
0
votes
1answer
31 views

Is it possible to add the all standard and custom objects list to the custom settings and use it in batch apex?

We are doing full org deployment, we need to update the record owner to system admin for all the objects records. So initially we created batch apex to implement this for accounts object. But we have ...
4
votes
0answers
44 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 ...
1
vote
2answers
42 views

Null Value assigned at initial value of For Loop, does this produce Null Pointer Exception Errors?

I'm getting a very weird scenario for a for loop. I'm running the following code: List<Id> conId = new List<Id>(); List<Customer__c> customers = new List<Customer__c>(); ...
-2
votes
1answer
41 views

How to get the current month and use in batch apex query

I want to get the current month from picklist field and use that current month in soql query in a batch class. I have written the following code and its not working. String month = Product.Month__c....
2
votes
1answer
36 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 ...
1
vote
2answers
54 views

How to address multiple update actions on account through batch process

I have a batch process that does a query on an address object with a recordtype for billing / shipping / mailing. When I update the account there are multiple updates. Would there be a better approach ...
0
votes
1answer
51 views

How to compare a duplicate list values and delete it

I have a use case where in 1 Order Contains multiple OrderItems, and these orderitems contains records. lets say there are 5 orderitems to 1 order, and among 5 orderitems 2 are duplicate and 3 are ...
0
votes
2answers
29 views

Catch System.LimitException in Batch to send error via Email

I created a batch that processes data based on certains parameters sent by the user and then sends the result via email. But sometimes the parameters are too ambitious and the batch throws a System....
0
votes
1answer
26 views

Batch Apex - Too many SOQL Queries 201 while reading CSV file to import data

I have a batch apex that reads a CSV file line by line, and then imports the data in it. Some of the fields of the data are related to other Salesforce objects, so when I read a line from the CSV (...
0
votes
1answer
37 views

How to loop over child objects of master object in batch object

I have a batch process to update Accounts with address info from the Cust_Address__c object. I use a Junc_Account_Address__c object as a junction. How do I loop through the accounts to update the ...
1
vote
0answers
29 views

Deleting ObjectPermissions record fails in apex batch but succeeds in two separate apex transactions

I have a Apex Batch job that "cleans" object permissions on permission sets automatically based on some rules. Essentially in each batch execution I am deleting all ObjectPermission records to a ...
0
votes
1answer
32 views

How to remove dom response from a loop

I have a dom class handler which I am calling from batch class. I am looping through the response to perform dml operations across certain objects. Since I have to use the response across different ...
3
votes
2answers
431 views

Query more than 50000 records

Inner query(b object in this case) is contributing to 50k issue. I need to count the number of records based on type and update the parent object. A - parent B - child Select id, (select id, type ...
0
votes
1answer
30 views

Batch Generated CSV attachement is cut

I designed a Stateful batch to some data and send it as CSV via email. And I don't know why but the attachement received in the email doesn't contains all the expected data, the CSV file il cut in the ...
1
vote
0answers
23 views

Bulk testing being restricted by limitation with Database.batchExecute() - How to overcome?

I was getting an occasional UNABLE_TO_LOCK_ROW error when two records were saved very close to each other. Related records were getting locked by one trigger invocation, and a second trigger ...
0
votes
0answers
27 views

Batch Apex - Try to create order while loading data

I have a batch apex that runs thru some attachments of a custom "Job" object that I made. There are 5 CSV files attached to this Job object, which I parse & create Salesforce records from. Now ...
0
votes
1answer
26 views

Pagination REST API, Multiple request, DML End problem

I was share 1 more question before in my profile, and i changed my apex code, My old question. Now i wrote my callout function in batch apex class, My problem is when i want to send second request ...
0
votes
0answers
43 views

How can i use pagination to in GET Request (REST API)

Firstly i want to update some fields in my products object, I was wrote API in my server for the products informations. In my Json data have a lot of records getting from the MSSQL Server, Thats why i ...
1
vote
1answer
34 views

Rest api Read Timed Out for large dataset

I have a rest request (user initiated via a lwc button) to an Azure Function that gets sent a masterId and followerId which contacts are assigned to. The Azure function uses a SOSL query. It will send ...
-2
votes
1answer
56 views

Batch Apex - Error related to Heap Size while Reading CSV [closed]

We have a batchable Apex where we read two CSV attachments on a custom object and we perform various operations on Accounts and Addresses that the CSV contain. The problem is when the files are a bit ...
0
votes
1answer
93 views

Too many callouts 101

I am making a callout to a webservice to retrieve records and upsert them into Salesforce. When I execute my batch class with a small set of records, they're inserted in Salesforce properly. However ...
1
vote
1answer
87 views

Batch Job Governor Limits

We have two custom objects - obj1 and obj2. These are related by a custom Id. We need to iterate through obj1, get its relevant records from obj2 based on Id and further query for permission of each ...
0
votes
1answer
27 views

Salesforce Platform Event After Specific Interval

My Use Case - After Every 5 minutes i need to get a token from "X-System" and need to store in salesforce. To Achieve this we implemented batch and scheduler. What Batch and Scheduler Will DO are ...
0
votes
1answer
27 views

Batch Insert List of Contacts from external data warehouse

So I need to use Batch Apex to insert some new contacts into our org. This isn't an overly massive list but there are other reasons it has to be done this way in our specific situation I won't get ...
6
votes
2answers
161 views

Current state of reliable execution scheduling

A number of approaches to more reliable scheduling and continuous processing have been used over time on the Salesforce platform, all of them suffering from serious drawbacks. These include: suicidal ...
1
vote
1answer
57 views

Executing Batch Class In For Loop - Flex Queue Limit?

We have a requirement of operating on data in present in different objects. The total record count (of all objects) ~ 50 millions (some objects holding ~20 millions records alone). So we have ...
1
vote
2answers
63 views

Converting attachment to files, heap size exceed exception

I am trying to convert our existing attachments to contentVersions using batch. But problem I am facing is that some of the attachments are of size greater than 12Mb. So when I try to run my batch I ...
0
votes
0answers
31 views

Checking no. of concurrent queued or active batch jobs vs. Checking no. of holding batch jobs in the flex queue

So Salesforce has one limit for the no. of concurrent queued or active batch jobs and a second one for the no. of holding batch jobs in the flex queue. If my understanding is correct, currently, all ...
0
votes
1answer
39 views

Variable does not exist - Batch Apex Query

I have a Batch Apex which is invoked from process builder. I can see Ids are coming into the variable (please see debug log) but same variable inside the query gives "Variable does not exist" error. I ...
0
votes
1answer
53 views

Aggregate Query on 900K records - how to do this?

Hello fellow developers, I need to run an aggregate query on 900K telephone records to add up a field (grouping by phone line id) and record results in the "summaries logbook". I have tried ...
1
vote
1answer
56 views

Best way to schedule a batch job repeating in short frequency

Requirement Run a batch in every other 15mins in the clock (i.e. clock time 00:15, 00:30, 00:45 01:00....). Method 1 - create a schedulable to run the batch every 15mins. Pros: it allows me, in ...
0
votes
1answer
71 views

How to do a recursive batch?

I need to do a batch which calls itself until a condition is true. I don't know how to start. I've tried some things but I got an infinite loop. The idea is: I have a start date Ex: 2019-01-01 Make ...
0
votes
1answer
25 views

Async apex job aborted manually from Apex Jobs Monitor - any way to catch that from the batch class?

I've just learned that finish() is never called when a batch job is aborted manually by a user from the Apex Jobs monitor. However, I would like to be able to run some logic in a batch class when its ...
0
votes
1answer
55 views

How to avoid Apex CPU time limit exceeded error with Process Builder?

We have multiple rules setup for Case using process builder but one of the rule seems to be failing throwing CPU Time Limit Exceeded error. The process is failing at this step where i am updating ...
2
votes
1answer
59 views

System.LimitException: Too many query rows: 50001 - How to solve it with a batch?

I need to create a summaries record for each result generated by the following query, which returns around 12K. The trouble is the aggregate result has to query 600K records, so I get 'System....
1
vote
1answer
46 views

Trouble with Custom Iterable in Batch Apex

I'm having some trouble implementing a Custom Iterable in Batch Apex. The goal is to update Accounts and Opportunties when information on the Owner's User Record has changed. Everything seemed correct ...