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
1 answer
30 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 ...
Kato's user avatar
  • 1
1 vote
2 answers
78 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 ...
Ameer's user avatar
  • 21
-2 votes
1 answer
45 views

Can we do DML in batch APEX start method [closed]

Is there a possibility to insert records in the batch Apex's start method?
sfdcDev's user avatar
  • 25
-1 votes
1 answer
103 views

How to fix Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch

Apex class : public static List<AggregateResult> calculOppN1(String userId, List<Id> filialeIds, List<Id> marketIds , Integer count , Date startDateN1 , Date endDateN1){ ...
Fark's user avatar
  • 17
1 vote
1 answer
102 views

I have an Accounts with multiple related Contacts. How can I retrieve only one Contact for each Account?

I have an Accounts with multiple related Contacts. My requirement is to retrieve one contact record for each account. If one Account has multiple Contact, I just want to retrieve one Contact record. I ...
newbieApexLWCDev's user avatar
-1 votes
1 answer
62 views

Create Excel file in Batch Apex Class

I am updating some records in my Batch Apex. I want to add those all records in some excel file and mail it. I am able to do this if i add all those details in a csv file instead of xml file by using ...
tycoon's user avatar
  • 3
1 vote
1 answer
41 views

Why is my batch showing error in test class but not in actual execution?

I have a batch that has a callout and it goes something like this. public with sharing class MyBatch implements Database.Batchable<Connection__c>, Database.AllowsCallouts, Database.Stateful { ...
Carl Ortiz's user avatar
1 vote
2 answers
452 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 ...
Emmanuel_M's user avatar
0 votes
0 answers
57 views

SOQL query error on CPU TImeout for Batch Apex

I have a Batch Apex operation that is part of a managed package that is failing in the start() method or soon after since the start() log is the last one displayed. I run a SOQL query that gets all ...
bswartz's user avatar
  • 27
-2 votes
1 answer
38 views

SOQL to get 3 months no stage movement on the opptuity

I want to make a batch class to auto closed lost opportunity if 3 months no stage movement Now I made this SOQL in Database.QueryLocator start: SELECT Id, Name FROM Opportunity WHERE Id IN (SELECT ...
Mustika Farma's user avatar
0 votes
0 answers
49 views

Unexpected behaviour when firing a apex method

I have this piece of code: public static void initTraitementBillingApi() { String methodName = 'traitementDPF'; ObjectUtil.debugLogBegin(CLASSNAME, methodName, ''); //String periode = ...
Fabien Braconnier's user avatar
0 votes
0 answers
27 views

Apex CPU limit exceeded on Batch start method

I have an scheduled batch that processes records but I'm hitting CPU limit exceeded error on start method. This is my code (SortLogicBatchQuery retrieves ~500000 records): public BatchSortProjects(){ ...
molinet's user avatar
  • 877
1 vote
1 answer
74 views

batch vs queueable for pseudobulkification of an app

I'm testing out an app that uses a callout to check some info in a government database and writes back any hits to a custom object. The app is designed to be used via an action on a record page, but I ...
gorav's user avatar
  • 4,485
0 votes
0 answers
96 views

Bulk API 2.0: Can I insert AND upsert in one csv request?

Edited to clarify: Background info on what I'm working on – we're going to be receiving email lists from clients, and we want to create new Leads or update existing Leads in Salesforce with the info ...
Brittany Layne Rapheal's user avatar
0 votes
0 answers
47 views

Async-safe mass delete of children with Batch

How to write in Apex a mass deletion (over 10 000 records, even up to 150 000) of related records that can be safely called from async context, like Batch? I have two custom objects, lets call them ...
zanstaszek9's user avatar
0 votes
1 answer
53 views

Execute a batch with custom delay between each batch processing

I have a batch class which update the primary field on the quote object using batch size of 1. I need to do this in such a way that each batch is processed 30 seconds after the previous one(there ...
Tony Jude's user avatar
0 votes
1 answer
27 views

Email in batch class

I am able to send email in batch class.But email is being send to Gmail only.It is not getting send to other type of email like company email. Execute method is working fine for other type mail but ...
Guest's user avatar
  • 3
-1 votes
1 answer
58 views

How to schedule an apex batch job at the end of each quarter

I want to write a cron expression to schedule a batch job at the end of each quarter i.e. 31st March,30th June,30th Sep and 31st Dec but unable to figure out how to do so. Has anyone done so ?
Aniket Srivastava's user avatar
0 votes
1 answer
57 views

Usage of Database.getQueryLocator

I am new to the batch class working, and I have a somewhat weird question. When I write this in the start method of a batch class: return Database.getQueryLocator([ SELECT Id, ...
RVK SF's user avatar
  • 9
-3 votes
1 answer
62 views

Hot to prevent Too many query rows: 50001 for a batch method

I have a batch class which I use to update a field of all historic records of an object. I have a trigger on the same object to update the same field when a record is updated. The trigger does exactly ...
Thomas's user avatar
  • 2,294
0 votes
1 answer
106 views

getContentAsPDF() from batch Apex request works in scratch org but not production

I have a Batch class that calls a Visualforce page using getContentAsPDF() to generate a single PDF. This works flawlessly in a scratch org and in the developer logs I can see a separate call made to ...
Dan's user avatar
  • 185
0 votes
0 answers
51 views

Salesforce Batch – Limitations (semi-joins, governor limits)

I need to write a Batch class to delete records from Child to Parents objects: Child__c --> Parent__c --> Parent_Of_Parent__c Every object has approximately 5 million records to delete, so I ...
Alessia's user avatar
-3 votes
1 answer
174 views

Send 1 Million records data to external system using batch class

I am trying to send the data to external system from batch class.. Where data include 1 million records.. I wrote below batch class. In batch class I am making callout to the external system and ...
K Sravanthi's user avatar
0 votes
1 answer
58 views

How to sum the values of an aggregated query

I have a parent object Account with related contacts these related contacts have (several) related statuses i.e. A B C. These are all the statuses a contact has had. On the parent Account I need to ...
Thomas's user avatar
  • 2,294
0 votes
2 answers
208 views

Is it guaranteed that First submitted Queueable or Batch class will run first?

We have to send case create and update data via API to third party. For create case: In trigger we are collecting all the case ids in set and calling queueable class if cases created are less than 100 ...
Sukruti's user avatar
  • 450
0 votes
1 answer
56 views

Deleting and re-inserting EmailMessage records along with Attachments

I have the following requierement: I need to recover some space in my org by taking all the EmailMessage records older than certain date and stripping the HTMLValue from them while keeping their ...
David de León's user avatar
1 vote
1 answer
71 views

System.LimitException: Too many query rows: 50001 when Using AggregateResult interface in batch class?

I want to aggrgate Average of Quality Score of Account object based on User's Market and I want to those summary details in one of Custom Object. I have written a batch class where I am using Iterator ...
SFDCDJ's user avatar
  • 1,814
0 votes
2 answers
76 views

A batch to insert 41000 task records [closed]

I want to insert task records around 41k. I used below batch class. This seems running but I can't find any records creating. public class BatchInsert implements Database.Batchable<Task> { ...
Sushil's user avatar
  • 3
0 votes
2 answers
138 views

Is each chunk of a batch Apex class transaction gets shared among the trigger which runs before/after each DML of the batch?

If a batch apex is called with size say 200 (default size). And we have a DML operation (say update) in execute method of the batch. So the trigger which is set to run before/after update will share ...
ItsVicky's user avatar
0 votes
0 answers
14 views

When will Aysnc method or Class will execute? [duplicate]

We have a case object subject field. When the case is created, Trigger fires and update the subject, then flows fire to update subject again..Now i have a future method or Queueable class or batch ...
Sukruti's user avatar
  • 450
-1 votes
1 answer
54 views

Independent Bulkification vs Batched Processing

I have been acquiring quite a bit of information about how bulkification and batch record processing works in salesforce (bits and pieces - salesforce documentation does not seem exhaustive). While I ...
Luke Sharon's user avatar
-1 votes
1 answer
40 views

Batch Processing

I have a batch class which is searching roughly 5000 leads and making a callout to an API depending on lead values. after the start batch the scope has roughly 1000 records to loop, and making a ...
CalDe's user avatar
  • 3
0 votes
2 answers
203 views

How do you pass a List of records to a batch apex class to be inserted?

I need to clone +10000 records. Yes,I'm aware of all of the limits and pitfalls associated with tying a trigger to a batch apex class. I'm accounting for it as only 1-2 people will be able to perform ...
Andrew Bloch's user avatar
1 vote
1 answer
421 views

Able to query deleted records from recycle bin but not to undelete them with system admin no role

How i deleted parent account (which caused related event or task records deleted itself): I've run a batch, which do dml and send other sobject records to be dml in other batch from finish. I had to ...
Ankit's user avatar
  • 19
0 votes
1 answer
56 views

Apex Batch stops after 2000 records

We have an Apex batch class which processes 2950 records of contacts, sending them emails with Messaging.SingleEmailMessage method(The query has a filter for IsEmailBounced = FALSE AND Email != NULL). ...
DavidS's user avatar
  • 37
0 votes
0 answers
15 views

Receiving Email body and Subject but unable to receive Opportunity Details

I have been getting email but only the subject and body but not receiving any details of the for loop their is no error showing and the batch class is running proprerly list<String> oppids = ...
Mr_Moon's user avatar
0 votes
1 answer
207 views

Queueable Apex - Too many DML Rows: 10001

Looking for some help with this. This class is failing due to the following error: 'Too many DML rows: 10001'. There's approximately 30,000 thousand records the class is trying to update, but I was ...
MattcG91's user avatar
0 votes
0 answers
87 views

Test Class for LightningURIEvent Batch Class

I wrote the following batch class to update a custom object when users view a record, this is for leadership reporting. The test class is throwing the error " A callout was unsuccessful because ...
Tariq McLeod's user avatar
0 votes
2 answers
113 views

Any suggested techniques to avoid a nested SOQL query when performing batch jobs?

We're currently running a monthly batch job to update a single field on every Account in our Org. We believe we were hitting governor limits so we have scaled back the batch size from the default of ...
kennyc's user avatar
  • 307
0 votes
0 answers
73 views

Best practice for deleting One Time Batch Jobs

As you know there is a common case like data cleanup and data migration or even the case when we add new field which should be populated on new records and we need to populate it on all existing ...
Dmitriy Yurkin's user avatar
0 votes
2 answers
25 views

Unable to send mail to Opportunityowner, Account owner and Creator

I want to send mail to Opportunity Public group , but I am not understanding where I am making mistake. I am using Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();. I have ...
Mr_Moon's user avatar
0 votes
2 answers
53 views

Salesforce Batch Resource Availability

Is it possible, that if i schedule a batch at 9pm and salesforce does not have a resuorces to execute the batch till 12am and then the batch will be executed the next day, 00:01am the next day?
Shubham's user avatar
  • 46
0 votes
2 answers
130 views

How to avoid nested for loop in this apex code?

public class TestUserData { public static HttpResponse makeApiCallout(String endpointUrl){ HttpRequest request = new HttpRequest(); App_Id__mdt appid = App_Id__mdt.getInstance('appid'); ...
sahil kakadiya's user avatar
0 votes
0 answers
54 views

Update sObject from Batch Apex when the sObject's other custom field value is invalid

So we have a situation where we have some custom sObjects that have some custom fields that are picklists. From time to time an Apex batch job runs to update picklists in Custom_Field_1__c. Now we add ...
zaitsman's user avatar
  • 1,890
0 votes
1 answer
95 views

Batch Class Test with History Object to Production problem

I'm a new salesforce developer, and i'm facin my first real world problem in my company. We have a custom object named "Solicitudes__c", is the detail side of a master relationship of ...
Arturo Alamilla's user avatar
1 vote
1 answer
245 views

How does Record Locking work in bulk uploads?

I am uploading about 800 records into salesforce using the salesforce inspector extension with the data import option. Per normal bulkification standards, the batches run in increments of 200 records ...
Luke Sharon's user avatar
0 votes
0 answers
56 views

How to get rid of 'UNABLE_TO_LOCK_ROW' while deleting multiple Group Members from a Group

I'm working on a scheduled flow which will delete all the Group Members present in a group after which I can add the required Group Members. But when the flow runs in scheduled mode it throws an error ...
nitesh kumar's user avatar
0 votes
2 answers
400 views

Make merge fields work inside the email template in for loops

I have a requirement where I am sending email via batch class. I have created an email template and I want to send data to the merge fields of the template from the code that I am writing. Since the ...
Rivu Indra's user avatar
0 votes
1 answer
271 views

Org Migration - Behaviour of batch jobs during downtime

Our org is slated to move from AP13 to AUS64 next week. The expected downtime is from 2 AM - 6 AM AEST (Sydney). Fortunately we do not have much user activity during this window but we have batch jobs ...
VPY's user avatar
  • 1,018
0 votes
1 answer
91 views

Nested list loop batch class

Hey i m very new to apex BMI__c and CMI__c are two custom objects I need to poplulate Id of a record from CMI__c to lookup Field of BMI__c in a batch apex class where bmlist is list of all records of ...
saurabh's user avatar

1
2 3 4 5
41