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
2answers
24 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
19 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
32 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 ...
-2
votes
0answers
24 views

Need help in passing parametere to test class from request body

Request body : { "StartDate": "2019-08-01", "EndDate": "2019-12-03" } Method : Post Need to pass these parameters in my test class not sure how i cna do this Test class : static ...
1
vote
0answers
17 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
27 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
412 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
22 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
26 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
21 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 ...
-2
votes
0answers
22 views

Is there some Trailhead API? [duplicate]

The Endpoint return only html. I want to restore points, badges and trails in Trailhead, but after change web site trailhead, it is no longer possible. public class RESTGetHttpContentCallout { ...
0
votes
0answers
32 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
32 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
47 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
84 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
81 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
26 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
159 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
51 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
53 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
37 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
47 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
55 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
48 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
19 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
48 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
55 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
45 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 ...
0
votes
1answer
36 views

Upsert error with apex batch job

I have a custom object named AttendanceRate with 5 fields "AttendanceRate_' + weekDay + -'__c' for each day of the week. When a user creates an activity, he has 100% of attendanceRate for this day, ...
0
votes
1answer
38 views

Trigger processing in batch

we have a trigger in before insert for Auto number generation and while doing a data loading of 300 records in batch size of 50. The first 50 records get saved but the second 50 gets an error stating ...
-2
votes
1answer
37 views

My Batch apex is covering only 50% test coverage can anyone help me to make it 100% coverage [duplicate]

global class FCSTCopyFinancialDataBat implements Database.Batchable<sObject>, Database.Stateful { Public string Query='SELECT Name, Account__c, FCST_Actual_Amount__c, ...
0
votes
1answer
26 views

Date Field-Driven Update

I have a custom object (Shift) with a date field (Start Time). I have a collection of tasks that I would like to update based on the Shift.Start Time. One approach I've looked into is setting up a ...
1
vote
1answer
60 views

Is it possible to call Database.executeBatch from a For loop

I am processing hundreds of thousands of call records that must be assigned to their respective telephone lines based on the phone number. I wanted to retrieve a list of Phone Line records and then ...
2
votes
1answer
36 views

I'm trying to create an APEX Batch Class on custom object, but getting an error

Getting an error when trying to create this batch class. Could you advise what I'm doing wrong? Error: Compile Error: Class LocationProcessorBatch must implement the method: void Database.Batchable....
1
vote
1answer
46 views

Test method fails with “Attempt to de-reference a null object” but code in class runs

I'm getting System.NullPointerException: Attempt to de-reference a null object when I run the test class, but the batch class will run without any issue. Here is my batch class: global class ...
0
votes
1answer
20 views

“INSUFFICIENT_ACCESS_OR_READONLY” while running a batch job

I get this error while trying to perform deletion using a batch job. I have all access to the object. In my case, Custom obj A is parent and B is the child (One to many). As per the code, when record ...
0
votes
1answer
26 views

Which one is the Optimize one when consider in a Batch?

Which one is the best way to optimize the performance if optimization available, Option 1: public without sharing class AccountTrigger extends TriggerHandler{ List<Id> accountIds; public ...
-1
votes
1answer
21 views

CRON Expressions every hour at specific times

Is it possible to run CRON job every hour at a specific time at that hour? I only ask because I want to spread out my scheduled batch classes throughout the hour to avoid maxing out the flex queue.
0
votes
1answer
49 views

Using Queueable Apex to avoid limit of 100 jobs in the flex queue

I am receiving the following error for some of my batches every here and there: You've exceeded the limit of 100 jobs in the flex queue for org 00D6A000000vKLe. Wait for some of your batch jobs to ...
1
vote
0answers
24 views

Reparent child records from different child objects

I have a situation where I have a parent object with around 15 lookup child objects. In a certain business scenario, the parent record will be replaced by another parent record, so that all these ...
0
votes
1answer
35 views

How to pause code until their is more space in the Flex queue

I am receiving the following error for some of my batches every here and there: You've exceeded the limit of 100 jobs in the flex queue for org 00D6A000000vKLe. Wait for some of your batch jobs to ...
-1
votes
2answers
31 views

How to handle error records in batch apex when trying to insert or update data to other object

I worked on batch apex which will insert or update contact object from SIS_Staging__c object. can anyone guide me how to handle error records here, from SIS_Staging__c object I am inserting or ...
1
vote
1answer
28 views

Ending position out of bounds: 10

I am trying to get the first 10 characters from "Patient_Name__c" field into the "Patient_Id_Help__c" field but when i run the batch class it is throwing the error as "Ending position out of bounds: ...
1
vote
1answer
42 views

Receive scope to batch from a function, without a query?

I need to update a huge amount of records, that are being updated by an integration. i have the following code: private void populateRelatedAssetsFields() { System.debug('LicenseTriggerHandler....
0
votes
0answers
35 views

How to design solution for querying 200k+ records and using that inside LWC?

I have a problem statement where I need to design an LWC component to enter policy information and check if that policy already exists in the system and print a report of those that aren't in the ...
0
votes
1answer
24 views

Queueable apex duration time issue

I'm running a Queueable that upsert contacts (in my example case it's just two contacts) and calling a batch with a Map < Id,String > - which Id is the Id of the upserted contacts, and the String ...
1
vote
2answers
139 views

How many records can an Apex Batch process

Finding mixed results within web searches, trying to locate a concise answer as to how many records can a batch process. I am creating an apex batch that will run daily. It will query around 55,000 ...