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
1 answer
74 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
350 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
175 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
89 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,864
0 votes
2 answers
83 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
316 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
15 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
67 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
59 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
638 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
1k 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
76 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
484 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
120 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
137 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
  • 349
0 votes
0 answers
109 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
26 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
77 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
188 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
60 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,930
0 votes
1 answer
173 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
443 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
103 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
665 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
389 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
129 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
0 votes
1 answer
112 views

whenever run the batch apex job I am Getting error like "First error: Field is not writeable: ProcessInstance.Status"

global class TimecardApprovalBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext bc) { // Query all Approval records that ...
Jhon's user avatar
  • 3
-3 votes
2 answers
80 views

I am getting null pointer exception on line 12 ( accIds.add(a.Id);)even though there are records , could anyone help me with it , Thanks In Advance

public class batchClassOnContacts implements database.Batchable<Sobject> { public List<Account> listOfAccounts; public Map<Id , List<Contact>> sizeOfContacts; ...
Manichandra Navuluri's user avatar
0 votes
0 answers
240 views

System.AsyncException: Database.executeBatch: batch apex job enqueue failed

I have a batch class which updates a set of records with data from an external system. About twice a month or so, this exception is thrown: errorCode":"APEX_ERROR","message":&...
Gabriel Gonzalez's user avatar
0 votes
0 answers
186 views

Enable Batch Apex process several records for related objects

I'm trying to write a batch class that operates on 2 related objects(Course__c and CourseDetail__c in a master detail relationship) and this batch has to look for all the child records of each parent ...
David Jake's user avatar
-1 votes
1 answer
175 views

Batch Import ContentVersion data via the REST endpoint

I am trying to upload a large amount of photos for Salesforce via the /sobjects/ContentVersion REST endpoint. Currently I am able to use this endpoint to upload one photo at a time. Is there a way to ...
EchoNano's user avatar
  • 101
0 votes
1 answer
110 views

Help-Logic to check if the submitted date/time is after 2PM and skip the update of that record- Batch class

This is the sample batch class that I am working on. This class is working fine but I need to add one more condition like, If status is set to submitted after 2PM, The number field should not be ...
sangeetha balasubramanian's user avatar
0 votes
0 answers
399 views

Is it possible to query archived records for a batch delete?

We've recently built a full sandbox and realized that our storage is over 130% capacity. Some digging found that there were 7million tasks taking up 94% of our storage. In order to use the sandbox, ...
user avatar
0 votes
0 answers
165 views

line -1, column -1: Method does not exist or incorrect signature: void executeBatch() from the type Database Stack Trace: null

I keep getting this error for every Apex Test when trying to move this Apex Class to production. It is an updated version to an old class that I did not make. I could not write this myself but I only ...
Kole Meehan's user avatar
0 votes
1 answer
23 views

What should I do to have all the data values in multiple batches?

I want to return a map containing the region and opportunity data called regOppMap and use it in another batch apex class called NewOppDistribution. It has been confirmed that regOppMap is used in ...
whytili's user avatar
  • 13
-1 votes
1 answer
278 views

Help with "FIELD_CUSTOM_VALIDATION_EXCEPTION" Batch class failed to update records

I have a similar batch class and the problem is not with the logic. public class SimpleBatch implements Database.Batchable{ public Database.QueryLocator start(Database.BatchableContext BC){ return ...
sangeetha balasubramanian's user avatar
1 vote
1 answer
416 views

Does it matter which Database.getQueryLocator method I use in regards to soql limits?

I usually use Database.getQueryLocator('soql string') when creating batch classes but I also see there's an overloaded method that takes a List of records, meaning I can use Database.getQueryLocator([&...
TemporaryFix's user avatar
  • 2,937
0 votes
1 answer
62 views

Is it possible to use results from a batch job in normal apex class?

I have a normal apex class, but since the no of records returned from a certain query (highlighted in code) is exceeding governor limits, I wish to replace that with a batch job, which will calculate ...
sourav guha's user avatar
1 vote
1 answer
768 views

How to solve "Invalid conversion from runtime type List<ANY> to List<String>"?

I'm working on a library that handles the exposes an iterable batch dynamically. Relevant code: public abstract class BatchIterable implements Database.Batchable<Object> { protected abstract ...
Tristan Martin's user avatar
-1 votes
1 answer
73 views

How to run a JS function residing in a VF page once a Queueable class executed from the controller class finishes its execution?

I have a command button in my VF page (ABC.page) - <apex:commandLink id="DownloadDOC" onclick="getAllDataForDoc('{!listOfObjects}')" title="Download Document" ...
Knight of the Vale's user avatar
2 votes
0 answers
83 views

Apex Engine old Version of apex code changed?

Recently (since January) we have encountered some cases when deploying new versions of our managed package. We have had at least 2 separate instances where changing a batch or an apex class referenced ...
Jose's user avatar
  • 2,142
-3 votes
1 answer
947 views

How to get success count and error count in batch apex [closed]

public void finish(Database.BatchableContext bc){ AsyncApexJob a [Select Id, Status, ExtendedStatus, NumberOfErrors, JobItems Processed, TotalJobItems, CreatedBy.Emailfrom AsyncApexJob where Id =:bc....
Guest's user avatar
  • 3
0 votes
1 answer
473 views

Batch Apex Unit Test: System.UnexpectedException: Error processing messages

I had a batchable class MyBatchable whose unit tests have been running successfully for over 2 years and suddenly, they stopped working yesterday with error Batch Apex Unit Test: System....
cropredy's user avatar
  • 71.4k
0 votes
1 answer
59 views

CPU--Limit Exception

I have written a batch which is giving APEX CPU LIMIT Exception, can anyone help. global class BatchTest implements Database.Batchable<sobject> { list<Account> AccountstoUpdate= new list&...
Ritwik's user avatar
  • 1
0 votes
1 answer
77 views

How can I add the RestContext.response in the batch class finish method?

I am creating a REST class wherein all the processing is done by a batch class. I would want the RestContext.response line to be made after the execute method. But it returns this error: "System....
Mae's user avatar
  • 339
0 votes
1 answer
207 views

how to create test data for the condition "Opportunity.LastActivityDate != null"

In my batch class, there is a condition that checks if(Opp.lastactivitydate != null || (Opp.LastModifiedDate > Opp.CreatedDate && Date.ValueOf(Opp.LastModifiedDate) <= Opp....
sirps's user avatar
  • 9
-1 votes
1 answer
311 views

Assign null value to Formula Field in a test class

Hello i have custom formula field name-sau__c on custom object NEw__c. In test class i need to passs null value to this formula field . to increase coverage of my code. formula field -Sau__c is ...
Saurabh Kumar's user avatar
4 votes
2 answers
1k views

How to avoid running a batchable when an instance is already running?

We have several batchables that if run in parallel trample over each other's results. So I want to block a second invocation if there is already one running and just tell the user to wait. My first ...
Keith C's user avatar
  • 136k
0 votes
1 answer
55 views

Hi, It is related to the batch jobs, while running the job, I am getting the below error

Exception caught: Merge failed. First exception on row 0 with id 0016900002e5Ka0AAE; first error: MERGE_FAILED, These accounts have the same related contact. Open the related contact record and remove ...
Khulas Khulas's user avatar

1
2
3 4 5
41