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.

learn more… | top users | synonyms (1)

2
votes
1answer
13 views

Batch Job with Custom Iterable throwing error First error: Invalid conversion from runtime type CustomIterable to System.Iterable

I get the error First error: Invalid conversion from runtime type CustomIterable to System.Iterable when trying to use a customer iterable in a batch job. My custom iterable class: global class ...
4
votes
1answer
36 views

Less resource expensive way to perform this scheduled task

I need to schedule anually a batch, on January 1st every year. This batch has to process all accounts to update a checkbox field. I'm trying to decide what is less expensive for the platform, so I can ...
2
votes
1answer
17 views

Explicitly change the context of User while scheduling a batch

I have a requirement where I schedule a batch to run via trigger on insert and update event. However, the batch schedules in the context of the User who makes the changes. Because of which the ...
2
votes
2answers
56 views

Working around callout limit in Batch Apex

I have a batch Apex class that makes a callout to an API that returns records in pages of 25. It also tells me how many pages there are so essentially I do - so I have a loop that then goes through ...
3
votes
1answer
27 views

Best way to automate updating contact emails in sandboxes post refresh?

I'm looking for a way to automate the process of updating emails of all active contacts in sandboxes (mask them with the .dev or .test). Number of records to update after filtering: 900,000 Things ...
0
votes
0answers
20 views

Data Loader, CLI “External_ID__C not specified”

I'm trying to import a CSV over the Data Loaders CLI. When I import manually using the same Account, CSV, and Mapping it works. Error: ERROR [ImportKF] client.PartnerClient processResult ...
0
votes
0answers
16 views

How to test batch with callout with triggers

I have been trying to write a test class for a batchable apex we have for a few days now, and I think I have identified that a managed package has a trigger that is causing a DML event on insert of a ...
0
votes
1answer
30 views

Do Trigger DMLs count on Batch Callouts? [duplicate]

Our instance has some triggers that fire before insert and before update on accounts, contacts, and leads. In a test class, if I am creating test records will the insertion of new account records ...
3
votes
1answer
54 views

Error: Too many query locator rows: 10001

I have batchable apex that is throwing the Too Many Query Locator Rows error: Global Class FocusDomainBatch implements Database.Batchable<sObject>, Database.allowsCallouts { global ...
0
votes
1answer
27 views

how to pull opportunity owner name in test class

I wrote a batch class to send email to opportunity owner when the opportunity's close date is passed. global class SendEmailToopsowner implements Database.Batchable<sObject> { global ...
0
votes
0answers
15 views

Performance degradation in salesforce sandbox - batches and asynchronous are taking too long time

We are running start of day and end of day jobs before and after the business hours, but from around 4 days we are observing even without any data sets the batches are taking too long to run. ...
0
votes
0answers
24 views

send email alert to opportunity owner when opportunities closed date has passed

I want to send email alerts to opportunity owners when their opportunity close date passed. Let say if an opportunity owner have 4 opportunities with same close date so only one email alert should ...
6
votes
2answers
362 views

System.LimitException: Too many async calls created: 2

I am trying to run two batches: 1.ContactNonEligibleMarker - Updates a status on the contact 2.RelationshipCreatorForContact - Creates child records(Relationship__c) under a contact. In the finish ...
-1
votes
1answer
22 views

how to create automated batch job with fixed width file format [closed]

My object name is Account and it has fields(length): Name (10) Account Number (8) Email (15) Phone (10) The query should fetch the data from the above object and download it as a fixed width text ...
0
votes
0answers
35 views

Facing issues with batch jobs in different sandboxes

I've built a batch job in our dev instance, that appends all the emails with '.dev' at the end, which is really simple and a common problem to avoid users getting sandbox emails, however, strangely ...
0
votes
0answers
29 views

Sending an email alert when query rows are more than 50K

We have a apex job in which we are fetching some records(SOQL) in execute method based on the record values retured by start method. But, there are more than 50000 records corresponding to one ...
0
votes
0answers
22 views

Update fields after clone in apex batch class

I have below code where I need to clone a record but change some of it's values. When I try that, it simply seems to do no change on newly cloned record. Can someone let me know how to achieve it? My ...
0
votes
0answers
20 views

how to send email to Account Owner from contract object in Batch Class

Can any one help me out . How to send an email to Account Owner from contract object in Batch Class.Im using templateid ,in target object im giving the contact id ,in whatid im sending the Account ...
1
vote
2answers
40 views

Batch Apex Query - when multiple batch jobs fails

Just a quick query on Batch Apex. Let us say I have about 8000 Opportunity records to process in our nightly batch job. The objective of this batch is to update a field on Opportunity if it matches ...
0
votes
2answers
25 views

how can improve code coverage of this batch class..i m sending data of query still data is not sending in batch class

this is my main class global class BatchJobContractRetention implements Database.Batchable<sObject>,Schedulable{ public void execute(SchedulableContext sc) { ...
0
votes
1answer
22 views

Clone record with changes in few fields

I have below execute method of an apex batch class where I need to clone Question_Response_vod__c records of existing with changes in few fields. Can someone please guide me here. I have in code to ...
-1
votes
1answer
30 views

Cron Schedule Mondays 6AM

How can I schedule this batch class to run on every Monday at 6AM? public class BatchCount implements Database.Batchable<SObject> { public Database.QueryLocator ...
1
vote
2answers
35 views

How to manage multiple data in input with a Bulk

I've got this problem to solve. I've an apex batch that updates some records all together when a condition is verified. This triggers a Process builder that calls an Apex Class or whatever it might ...
-1
votes
1answer
28 views

Test Class is not getting covered Messaging.SingleEmailMessage in batch class

Test Class is not getting covered for singleemailmessage. Part of Code : global void execute(Database.BatchableContext bc, List < Contract > recs) { List < ...
0
votes
1answer
38 views

Help in test Batch class

I have a Batch class and written a test class where the code coverage is displaying as 50% only.How to cover the single message email in the test class . Batch Class : global class ...
1
vote
1answer
32 views

How to do searching from 10 million records [closed]

There is an object and it has approximately 10 million record and i want to apply searching in VF page can any one tell me how to do that without reaching the governor limits. Any idea or some code ...
-1
votes
1answer
32 views

how to add if else condition in batch class

Based on the requirement i have a Batch Class . Small info needed ...in query locator i have given the conditions for all needed .Now i would like to add if - else condition for one of the condition ...
1
vote
0answers
19 views

Using email templates where targetobjectid is user

Objects: Obj1 and Obj2. Obj2 is child of Obj1. Obj1 has a lookup to user object(User__c). I have a batch class wherein i am trying to schedule emails. I want to use an HTML email template. The ...
1
vote
2answers
69 views

SendEmail failed. REQUIRED_FIELD_MISSING, Missing targetObjectId with template:

Can any one help me out with this error . 1)When im using mail.setTargetObjectId(c.CustomerSignedId); the system start throwing a error . SendEmail failed. First exception on row 0; first error: ...
0
votes
2answers
34 views

Batch Class add condition in the query

I have a batch class where would like to add few condition in the query,how to add them.Any Suggestion please. 1)I would like to add more roles (such as EB ,TA ,RA etc where role is a picklist field) ...
2
votes
2answers
81 views

Concurrency issue on Batches

I have two batch classes that run concurrently. Let's call them Job A and Job B. Job A inserts records in object A. And Job B in object B. Object B has a lookup to Object A. Because this lookup is ...
1
vote
2answers
23 views

How to make callout from a batch class without Statuscode 500

I have a batch class which basically does a soql of to get a list of account records. In the execute, i want to get the list returned and pass them to a Http callout function which will do a Post ...
-1
votes
1answer
25 views

Batch apex email query

Leads that are older than 1 month with Approval Status ‘Rejected’ should be emailed in the form of an ‘excel file’ to the System Administrator predefined in custom setting and should then be deleted ...
0
votes
1answer
17 views

How to write a test class for HTTPCallout in batch class

I have a batch class which contains HTTP callout, I have seen the blogs for it httpcalloutmock, But I am not understanding how to do it in batch class. Any help is very much appreciated, thank you.
3
votes
2answers
55 views

Batch Class Error as System.StringException: Invalid id at mail.setTargetObjectId(c.Owner.Email)

I have a written a Batch Class to send an notification email 60 days before the contract end date.I have created the email template and used in the code.But the system throws an error as : Batch ...
0
votes
1answer
18 views

How can I call a Batch class from test class?

This is my batch class: global class changeMultipleContactName implements Database.Batchable< sObject > { global String name; global String n = 'Helly'; global ...
6
votes
1answer
60 views

Batch Apex - Need help

This is my first time trying to use batch apex. I copied the example from Trailhead and attempted to move my class code into it. I don't think I have the aggregate query coded correctly but I don't ...
0
votes
0answers
19 views

Batch is scheduled but cannot see any run logs in 'Apex Jobs'

I have a batch scheduled as can be seen in ‘Scheduled Jobs’ but somehow I am not able to see the logs in ‘Apex Jobs’ table. Therefore , I am not able to understand if the batch runs or not. I have ...
2
votes
1answer
85 views

How to create thousands of records using batch apex

I have a scenario where I have to create 30000 contacts and 15,000 accounts (i.e. 2 contacts per account) in an org. I have been trying to do this by using batch apex but I still have error of "First ...
2
votes
1answer
44 views

SOQL Limit Hit - Aggregrate

My query hit the 50,000 record limit. Can someone help me rework the query so it operates within the limits. For reference, we have one account that has 92,000 active employees. The aggregate ...
0
votes
0answers
26 views

Test class not executing scope

I am implementing a batch to delete few records. I am querying in start for records to be deleted and deleted the whole scope like this, public void execute(Database.BatchableContext info, ...
3
votes
1answer
39 views

Catching exceptions when using Batchable with custom Iterable/Iterator

When using a custom Iterable/Iterator class with Database.Batchable, if the Iterator throws an exception it seems impossible to catch the exception. Is there any way to catch the exceptions thrown in ...
0
votes
1answer
25 views

issue adding csv file attachment to email in Batch job

In a batch file we are updating records, and for each one we are creating a record which is sent in an email when the batch completes. It all works swimmingly except that the csv file is sent as an ...
0
votes
0answers
26 views

Attchment on Opportunity in Batch apex

I have a requirement of creating an excel or pdf from batch apex. I insert few records in batch on some business logic. There are few records which i skip from creation if the logic is not satisfied. ...
5
votes
0answers
22 views

Behavior of QueryLocator in Batches [duplicate]

I have a batch job that reads records from a table and does some processing. During the execute method, these records are deleted. This job can, under certain circumstances, be running more than ...
4
votes
2answers
78 views

Testing scheduled apex: CronTrigger does NOT fire after Test.stopTest()

EDIT for clarification of title: CronTrigger is probably actually firing at some point in the testing process - what is wierd is that CronTrigger.TimesTriggered is NOT incrementing after ...
1
vote
2answers
43 views

Why we can not create our own batch interface? [closed]

why we need to implement database.batchable interface,instead we can create our own interface and implement it. why we can not do it,even we can make an interface in apex,so could be exact reason for ...
1
vote
1answer
82 views

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

I am getting a strange error when running my test method: @isTest public class Batch_Ent_Update_Eqn_Status_TESTMETHOD{ public static testmethod void testBatch_Ent_Update_Eqn_Status(){ ...
1
vote
2answers
53 views

how to write test class for Batchable

global class operationsDeleteBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'Select id from ...
4
votes
0answers
70 views

Database.Stateful and Database.SaveResult in a Batchable class giving internal errors

Usually when I write a class that implements Database.Batchable I end up saving errors in a variable(s) to sort through in the finish method and send out something about successes and failures. This ...