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
-2 votes
0 answers
31 views

System.debug() is not displaying when running a batch class

I have a batch class that is just querying for some records, and have included some system.debug so i can see what is being outputted, though in the logs, the 5 logs that are being created, none of ...
1 vote
1 answer
51 views

Retrieve Batch Class Name from Trigger

In order to cover a specific requirement, I need to determine that the DML action of inserting the records of an sObject has been triggered through a batch. The System class provides the isBatch() ...
2 votes
1 answer
53 views

Batch job sporadically not updating/creating some records

I have an issue where my batch job seems to be choosing a random amount of records to not update/create. There is no error thrown from what ive seen, and I do not have a try/catch that would allow for ...
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 ...
0 votes
1 answer
1k views

Monitor Bulk Data Load Jobs Remain "In Progress" even when there are no more batches to complete for the job

As the title suggests, I am loading data into Salesforce via the Python Simple-Salesforce Library. For some reason, the jobs that are fully complete, are still showing up as "In Progress". I ...
1 vote
0 answers
28 views

Create Opportunity & related OpportunityHistory Test Data

I've written a batch job which queries a bunch of Opportunity records and their related OpportunityHistory records to capture data from the history records on the Opportunity. This is working as ...
-1 votes
0 answers
12 views

how to use Lastlogindata test code

Last Login data is readonly, so the field cannot be changed. So how can I write test code for that field? I have a batch code that excutes and processes the lastlogindate from a certain period of time ...
0 votes
1 answer
23 views

If an underlying record changes before a batchable gets to the record is it still run/uses the latest values?

two examples I am running the query [SELECT Id From Account] to select all accounts. The batchable gets to the account (Name='Steve') and in the mean time the underlying record has changed to (Name='...
0 votes
1 answer
827 views

Find job status using the id returned from Database.executeBatch?

I have a class that is Database.Batchable which I execute via Database.executeBatch. How do I find the job status Id using the id returned from Database.executeBatch? It doesn't seem to match the Id I ...
26 votes
6 answers
38k views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
0 votes
0 answers
31 views

What is the difference between SingleEmailMessage and MassEmailMessage?

While i'm sending Email for 30 records both are getting Limit exceed Exception Through Batch apex i give batch size as 10 but still getting exception.This is my code global class ...
0 votes
0 answers
28 views

Best practice to deal with HATEOAS api callouts

I'm creating an connector between Salesforce and a ticketing system that exposes a REST API based on HATEOAS. I need to synchronize tickets everyday and insert/update them as Cases. Salesforce is ...
0 votes
1 answer
31 views

CSV report generation using apex batch

I am trying to generate the csv report by fetching the data from ApexTestResult obj. But the column 'message' in the apextestresult obj is overlapping and automatically divided the message and showing ...
2 votes
1 answer
71 views

LWC Export query results to Excel/csv where rows > 2000 prior to delete

I have an LWC where I run a query to clean up/delete records. The LWC works fine for showing 2000 rows at a time in a datagrid (although 2000 is a bit of a big grid so I set 2000 as the max but ...
0 votes
1 answer
32 views

How to test Batch Apex Heap Size Logic?

I have a batch class that implements Database.Stateful and it is filling a Map collection at the execute method alongside other things. This map is then utilized to send emails related to the records ...
19 votes
2 answers
737 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: |-----...
0 votes
1 answer
57 views

Mocking a Batch class?

Is there any way to mock a batch class for unit testing and predefine the scope passed to execute method? I am using a selector class method for Database.getQueryLocator at start method. public class ...
0 votes
1 answer
46 views

LWC delay refreshApex until batch job completes

I have a datatable in an LWC where rows can be selected for deletion. The delete process is done via a batch job due to multiple triggers running for the object being deleted. Once I've kicked off the ...
0 votes
1 answer
852 views

Test Class Coverage for Scheduled and Batch Classes

I am attempting to test a scheduled class that calls a batch class to update records. The following test class does not seem to find the Opportunity being created in the test class to pass that list ...
1 vote
0 answers
37 views

Error : unable to obtain exclusive access to this record while posting the Invoices

I have build the custom logic to post all the invoices by clicking on Lightning Button. It retrieve the Invoice Run Id and get all the invoices that are in Draft stage. I am sending in batch size of 5 ...
1 vote
0 answers
41 views

Managing state in object graph spawned by Batchable

Prelude I understand the following regarding batch Apex: State Variable Values stateful static are reset for each batch execute() run instance (non-static) are maintained across all batch execute() ...
0 votes
0 answers
80 views

Pass Map from Batch Apex to VisualForce email template and iterate on it

I have a Batch Job called ContractExpirationNotificationJob and it identifies expiring contracts and sends the owners a list of expiring contract records by email. Currently, I am using a method ...
0 votes
2 answers
1k views

Unable to insert the records in my custom object using batch Apex

Thanks in advance. I have a batch apex code here. I want to insert the records into my custom object. what is the code for inserting the records. global class WeatherForecastBatch implements Database....
0 votes
2 answers
43 views

Test Class coverage on execute method of Batch Apex which is Scheduled to run at specific interval of time

I have a Batch class, which queries Lead records that were created 1 day before. I have created a custom Label 'More_Than_1_days' which has the value 1. I was using this custom label in that batch ...
0 votes
0 answers
43 views

Several updates on Case record withing short period of time causing "duplicate value found: <unknown>"

I have pretty complex process starting with scheduled Batch Apex, calling my Mulesoft endpoint to retrieve some data and save it on Case record: Batch apex request from Salesforce to Mule is ...
0 votes
0 answers
37 views

Batch Class - Performance Optimization

I have a batch class which converts attachments to Files for old records in the system. We are running with batch size of 20 to 25 for the attachments to convert to Files but the conversion process is ...
0 votes
1 answer
1k views

execute method of batch apex not running from anonymous window

I have a batch apex that I made few changes. The functionality of the batch apex is to pull assets of a specific record type, and updates a specific field to true based on a criteria. To test my ...
0 votes
1 answer
80 views

Working with regex on big Strings (Avoiding Regex too complicated error) [duplicate]

Is there a way to divide/simplify a pattern match to avoid getting this error ? Sometimes the Json String that I'm trying to match is way too long and it causes errors on a batch a class. I am ...
0 votes
2 answers
1k views

Batchclass How to get start variable in execute method

I want to get the metaapi variable in the execute method. global static IntelligratedAPI__mdt metaapi = new IntelligratedAPI__mdt(); public String query; global Database.QueryLocator start(Database....
-3 votes
1 answer
60 views

System.FinalException: SObject row does not allow errors on Batch

i am trying to create a batch that prevent from creating duplicate records. This is my classes and trigger Class batchCheckDoublonContact : global class batchCheckDoublonContact implements Database....
1 vote
1 answer
4k views

How to display Batch Record Process Count on Progress Bar Indicator in LWC?

I am currently working on functionality where I am assigning Bulk Records Ownership to new user. For this, I have designed LWC and which calls helper class. and the helper class call a batch class to ...
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 ...
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 ...
1 vote
1 answer
1k views

Flow of Batch Apex Code

"BatchJob_Obs" Class global class BatchJob_Obs implements Schedulable{ global void execute(SchedulableContext sc){ List<Operating_Business_Status__c> waiting_to_process_list = [SELECT id,...
1 vote
1 answer
103 views

SSJS script is timing out at 30 minutes. How to I build series of scripts using rownum to parse the DE sequentially?

We have an SSJS script that is calling an API to fetch price of items and writing it into a DE. The API call is taking time and in 30minutes the script is only able to retrieve the price for ~6000 ...
0 votes
2 answers
1k views

Email Limit Exceeded on Batch Apex

I have a batch job which sends email notification in bulk using Messaging.sendEmail() and its using setTargetObjectId to set the reciepient. It sends out thousands of emails but one day I got case ...
1 vote
3 answers
1k views

Execute batch working when executed anonymously but not when called from my vfp controller

I have a controller that extends a vfp that calls execute on a batch BatchableScorer bs = new BatchableScorer(passedContacts); ID batchprocessid = Database.executeBatch(bs); though when it fires ...
2 votes
2 answers
2k views

Calling Flows from Batch Apex and making the Flow.Interview Class Bulkified

I am running a scheduled batch job daily on 25,000 records and growing. I Want to be able to leverage Salesforce Flow for processing the data because it gives more control to the Admin for ...
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 ...
0 votes
0 answers
77 views

How to store large amount of data in a variable for a batch bypassing heap size exception

I am stuck with the following error: 'Batchable instance is too big: ProductDiscountsFormatterBatch' I have a junction object called Account_Product_Discounts__c with the information of, for each ...
2 votes
2 answers
4k views

Bulk sending CustomNotifications using APEX

I could not find any post relating to this any help will be appreciated. Is there anyway to bulk send custom notifications from apex without using a process builder or API? If I use the following code,...
1 vote
1 answer
74 views

Test System.Limit Exception Handling with BatchApexErrorEvent

I want to provoke a System.LimitException in a test method, so I can test BatchApexErrorEvent trigger that is supposed to handle uncatchable exceptions like CPU-Timeout etc. However the LimitException ...
1 vote
1 answer
2k views

Apex Batch that Calls a Vlocity Integration Procedure

I have a batch apex that executes a Vlocity integration procedure for every record in the loop. I'm facing the problem of 'First error: vlocity_cmt:Too many SOQL queries: 201' Do you have any idea ...
0 votes
1 answer
234 views

Error while creating a test class - DML operation Insert not allowed on Survey [duplicate]

I have created a apex batch class to create survey invitations, subject records & send the unique survey links to participants. Trying to write a test class to cover it by inserting a surveybut ...
0 votes
1 answer
869 views

Is that possible to call batch class from trigger for more than 2K records to do callouts?

We want to do call to batch apex from trigger. And in that batch apex class we want to do callouts. So we are giving batch size 50 in scope parameter. but we have more that 2K records which we update ...
-1 votes
1 answer
117 views

Can we do a callout inside for loop in batch class

Callout class Public class calloutValidation{ public static string CalloutCheck(String Email{ try{ //There are some logic HttpRequest req = new HttpRequest(); ...
0 votes
1 answer
50 views

Salesforce System.AsyncException - scheduled class calls Queueable apex do a callout and then calls batch apex

I have a schedule apex class that calls Queueable apex which calls a class that do a callout and then execute batch. I receive System.AsyncException: Database.executeBatch cannot be called from a ...
-2 votes
1 answer
363 views

Which is a better approach when updating records using batch class, to place it in execute or finish method?

Sorry but I am new to this and I just wander, do you think it is better to put all the millions of records inside the Map object which is process by the execute method, however the dml where the ...
1 vote
2 answers
91 views

Batch Apex Class Invoked From Before Delete Trigger is not deleting Files Attached to accounts

I have written a batch class to delete the files related to an account whenever an account is being deleted. When I have tried the same code and logic without batch class it works fine. But in batch ...
1 vote
2 answers
511 views

Dynamic SOQL Error: Unexpected Token ':' - I have searched for two days, what could I be missing?

I have a batch class that will be performing some actions over selected Case records. The only problem with this batch class is the Start method. When the query is returned and processed, it returns ...

1
2 3 4 5
41