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
1answer
17 views

Passing a second parameter to batch process

I have the following block of code that is working. However, I need to pass an additional field that will be used in the FINISH block to save a custom metadata value for the next time the process ...
1
vote
1answer
33 views

Throw a DML exceptions in Apex Batch Class for testing

Below is my batch apex class that updates Account object for example: global class abc implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext ...
-2
votes
1answer
35 views

Question regarding batch apex salesfroce

I am updating the contact information based on another object activity by comparing the contactid of the value. if the activity having multiple records i want to update the contact with recent ...
1
vote
2answers
93 views

Managed package batch failing to execute with error CPU time limit exceeded

I am trying to understand why managed package batch is failing. From the below screenshot, can we assume that it failed in the start method itself? or entered first iteration of execute method and ...
1
vote
1answer
54 views

Execute method within batch APEX not firing from test class

I have written the following batch apex class and corresponding test class. Tests are successful but the execute method is never called. I have attempted to debug to try to pinpoint the problem but ...
0
votes
2answers
33 views

Passing method parameter to the start method of batch class

I have a below batch class where I am passing 100 account ids to the constructor and in the debug logs I can see 100 in constructor as a set size but in start method I can see 0, could someone please ...
1
vote
0answers
29 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 ...
-3
votes
0answers
26 views

Inner query in batch apex [closed]

I need to write inner query for six object in batch apex.But we have limit of 3 objects in batch apex. how to do that?
1
vote
1answer
34 views

Finish method of batch class is not invoked when error occurs

I have a batch class that http callout in the start method. Also, wrote an some block of codes to send notification when something went wrong in the finish method. However, when api return ...
0
votes
1answer
38 views

DML in @Future called from Trigger in Batch

I have a after insert trigger on an object that calls a @future method to do a callout to an external system. If the callout fails I want it to update the original object. I am batching up 100 at a ...
1
vote
1answer
54 views

Batch->Queueable->Callout+DML ::: Uncommited work pending issue

I am having following structure, where I am getting issue- CalloutException: Uncommited work pending. Ideally, with Queueable it should not throw the same error(since DML is happening at last in ...
1
vote
1answer
35 views

Can i improve code coverage for loop in batch apex

Firstly I wanna protect my organization code coverage, My scenario is as follows; I wrote 1 batch apex process, for calculate cycleTime to every products, am getting %80 covarage with this code but ...
1
vote
0answers
28 views

How does flow accept input parameters from batch class

I have an apex trigger and a batch class. I am running apex trigger on contact, sending it to batch class and from batch class sending the parameters to flow. Trigger: trigger BulkContactsLoad on ...
2
votes
1answer
134 views

Is there any way to extract more than 50k records inside execute method of batch?

I have a batch working on approx 40k records in chunks of 200 records. Inside execute of the batch I am querying from one abject returning more than 50k records. Getting 500001 error. How to remove ...
0
votes
1answer
29 views

Batch class for insert and update

I need to write batch class for inserting records to one standard object(case) to custome object. also if any record get updated, then it should also get updated in custom object also. i wrote below ...
0
votes
1answer
25 views

Apex Batch slow

I've launched an apex batch but each processed batch is too slow. Looking at the duration of each execute method, I see that the duration is around 2.668 ms but the next execute method is processed ...
1
vote
1answer
62 views

How to force future method to wait until current thread finish?

I have an apex code which is called from an after trigger. The apex code calls a future method and sometimes the future method runs after the execution of the current thread and sometimes does not. I ...
0
votes
1answer
29 views

Custom Roll Up Summary - Batch Apex/Trigger/etc

I want to make a roll-up summary-like field between two objects with a lookup relationship. The relationship can't be changed into master-detail so I'm writing some custom code to do this. Since it ...
0
votes
0answers
18 views

Query for Contacts on Accounts in Execute Part of Batch [duplicate]

List<Account> Scope = [SELECT id FROM ACCOUNT]; // This is the query being used global void execute(Database.BatchableContext BC, List<Account> scope) { List<Account>...
0
votes
0answers
21 views

Test class for batch apex with email message [duplicate]

global class Email_payment implements Database.Batchable<Sobject>,database.stateful { string email; List<Contact>emailids=new List<Contact>(); global Database....
-4
votes
0answers
68 views

CPU time out error in batch. Records processes 12746

`` ErrorTempSSP1Data ins = new ErrorTempSSP1Data(); for(EQ_TempSSP1Data__c record : tempSsp1Data) { distinctTempSsp1DataSourceSystems.Add(record....
0
votes
1answer
26 views

Update related record with batch class

I'm running a batch class over the Timesheet object and for the timesheets that meet the criteria, I want to update the related Contact record. I have a jstcl__TG_Timesheet__c object with a field ...
2
votes
0answers
58 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 ...
0
votes
1answer
33 views

Callout from batch issue

@RestResource(urlMapping='/UsageInputDemo/') global class APTS_UsageInputWSDemo{ @HttpPost global static void loadUsageInputsDemo() { RestRequest req =RestContext.request; Blob body = req....
1
vote
1answer
24 views

Clone Data of big Object into another big Object

I have roughly 10 million records in Big Object and now I need to move the data/clone the records in another big Object. The reason why I am doing this is that I need to modify/add more fields to the ...
1
vote
0answers
38 views

Testing Batch Apex with Big Objects

I have a batch apex class that uses Big Objects for processing. However, when running tests on this batch class, Salesforce throws an error not allowing Big Objects to be inserted for testing: https:/...
0
votes
0answers
15 views

How to build query to get all data from TopicAssignment?

When run "SELECT Count() from TopicAssignment" in our code, it fails with error: Implementation restriction: TopicAssignment only allows security evaluation for non-admin users when either (1) ...
0
votes
1answer
35 views

Compiler error with the batch

public with sharing class APTS_UsageInput_InsertTempRecordsBatch implements Database.Batchable<APTS_UsageInputWrapper> { public List <APTS_UsageInputWrapper> inputList = new List<...
0
votes
0answers
33 views

Apex batch job failing with “First error: Read timed out”

I have a batch job that is failing with the following error First error: Read timed out In the debug log, I got the repsonse as FATAL_ERROR|System.CalloutException: Read timed out When I ...
0
votes
1answer
25 views

Stop Running Batch class called from finish method

I wrote a batch class and called same batch class from finish method without any time interval, Now I am not able to stop it.. global class SaveFileIntoDropbox implements Database.Batchable<...
0
votes
1answer
24 views

Need help with Test coverage of batch apex error- System.InvalidParameterValueException:

I am trying to write a test class for the batch apex class, but i am getting an wierd error(System.InvalidParameterValueException: Provide the ID of a test-context sObject as the first parameter for ...
-1
votes
1answer
47 views

How to get more than 50K records in a trigger handler from SOQL [closed]

I have a requirement where I'm getting more than 50k records for a single parent id, and I need those whole records to process them. I now batch is the best option to use but that would be time ...
-2
votes
1answer
46 views

Map is always getting null value when i access locMap

global with sharing class InventoryCountBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC){ return Database....
0
votes
0answers
24 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
72 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
33 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
30 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
46 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
39 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
37 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
4answers
157 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
46 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
142 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, ...
10
votes
1answer
392 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
46 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
33 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
45 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
43 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
49 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....

1 2 3 4 5 30