Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
2answers
10 views

System.QueryException: expecting a colon, found New

String emailBlastQuery = 'SELECT Id, Inquiry_Type__c, Product_type__c, Solution__c, Reason_For_Calling__c, '+ 'Problem_Category__c, Duplicate_Case_Problem_Category__c,...
1
vote
1answer
27 views

Can we avoid 'Attempted to schedule too many concurrent batch jobs in this org' error using Apex flex queue?

We have a batch class AccountDeactivationBatch from whose finish() method we run 3 more batches, including AccountDeactivationBatch again, but with new set of Ids. These new set of Ids are all ...
0
votes
1answer
20 views

Iterator and Iterable issue - must implement the method: System.Iterable<SObject> Database.Batchable<SObject>.start(Database.BatchableContext)

Unlike OP in this question, I am using a custom iterator and I'm getting the same error as stated in the title. This is my first attempt of writing a custom iterator and I'm having troubles compiling ...
0
votes
0answers
14 views

Which Salesforce IP range to whitelist for an integration through scheduled apex batch

My situation is the following: I have a batch that is scheduled to run every hour, which does a callout to an external system. My org is located in the APAC region, but the user that scheduled the ...
0
votes
1answer
24 views

How to display Data in tabular format when Posting it to Chatter via Apex?

I have a requirement where I want to send email notification to User if Opportunity Close Date is last 10 days and send Chatter Feed notification when Opportunity Close Date is Last 3 days. For this ...
2
votes
1answer
17 views

Is it possible to call Database.QueryLocator start() when you only have a reference to the interface?

I'm trying to build a general-purpose piece of functionality that can be added to batch classes. My class is Batchable itself and it will take in an instance of another Batchable. For each of the ...
0
votes
3answers
53 views

Avoid 'Apex CPU time limit exceeded' with Batch Process

I encountered this error and have trouble with performance tuning. I tried asyncronous approach, but Apex CPU time limit exceeded occurs continuously. Anybody can make it more efficient? Here is ...
1
vote
2answers
191 views

Batch APEX requiring two queries and hitting limits

I have a batch APEX class that is used to delete any contacts that have been created over a year ago and have no related opportunities. I have queries for the contacts in the QueryLocator. I am then ...
0
votes
1answer
16 views

Batch apex class use fetch account data with Email Message

i wrote a Batch apex class, and i will fetch the all Account Records, But in account having Phone value is Null for Some Records, Those Records will be send to Admin user Email, How to do this ...
0
votes
0answers
18 views

Send direct messages via ConnectApi (batch)

I want to send notifications to individual users in a Salesforce community. These notifications are created in Apex and sent to users. I have a list of messages and the recipients. Since this will be ...
0
votes
1answer
36 views

Query ContentDocumentLink in a batch gives Internal Salesforce.com Error

I have a batch where I first query some ContentDocumentLink. If the query has some results, I got an internal Salesforce.com Error when the batch start during the SerialBatchApexRangeChunkHandler ...
0
votes
1answer
38 views

Identify and mark duplicate records in Opportunity using Apex and SOQL

I have about 400K records in opportunity object which needs a cleanup of duplicate records using a batch class. I don't want to delete the duplicate records, I want to check them as 'prospective ...
0
votes
0answers
27 views

Not covering batch execute method querying CampaignMember

AccountActivityUpdateBatch class execute method is not covering the for loop. Here is my test class. @istest public class AccountActivityUpdateBatchTest { @testSetup static void setup() { ...
2
votes
1answer
29 views

What is the real limit of enqueueing Batch apex?

According to Apex Developer Guide, the limits on Batch Apex are the following: Maximum number of batch Apex jobs in the Apex flex queue that are in Holding status: 100 Maximum number of batch Apex ...
0
votes
1answer
24 views

Apex CronTrigger Throws error while aborting: Job does not exist or is already aborted.

I keep getting this error when I try to abort a scheduled job in my batch job code. Below is my code: Datetime dt = system.now().addMinutes(Integer.valueof(myCustomObject.Time_Interval__c)); ...
0
votes
1answer
30 views

Mass Update Records - AWS S3

Currently, I utilize an AWS endpoint that returns a small JSON response based on my request. I am considering updating all of my records (300,000+) daily. My AWS counterparts can generate a JSON ...
0
votes
1answer
55 views

How is the batch size been decided?

I have a Batch job with limit 20000 records in the Start method. And while executing I have put batch size to 900, according to the documentation i should get Total No Records/Batch size this will ...
0
votes
2answers
34 views

Best Practice to schedule a Batch

I am looking to find a best practice/framework to implement a schedulable batch. I don't know if create an Apex Class that implements Schedulable and Batchable interfaces is the correct way or create ...
0
votes
1answer
46 views

Script-thrown exception in Test class for Batch apex callout

I have a batch class which makes multiple http callouts to an HR system and then with the absences returned checks for existing absences and upserts. However when I try and run test class for the ...
1
vote
1answer
124 views

Batchable & Schedulable class has cyclomatic complexity of 48

Background I have a class which implements Database.Batchable<Sobject> and Schedulable and when I run PMD I get this problem: The class 'MyClassBatchJob' has a total cyclomatic complexity of ...
-1
votes
1answer
37 views

System.TypeException: Invalid date/time: 2018-09-18T16:57:37Z

I'm getting Invalid date/time: 2018-09-18T16:57:37Z in the developer console. please help me with this DateTime dt = Datetime.now().addMinutes(-10); String formatedDt = dt.formatGMT('yyyy-MM-dd\...
0
votes
1answer
42 views

create 100K records of custom object using Batch Apex Salesforce

I am trying to create a batch class to insert a custom object. The following is the code, global class EmployeeBatchCreate implements Database.batchable <Integer> { global Iterable<...
2
votes
2answers
57 views

Read through small CSV file returns Regex too complicated

I have a method which reads through a CSV file and if any of the columns match my keyset prepares them in an sObject, with my test files which contained 1,000 records but only 4 columns this worked ...
3
votes
1answer
34 views

batch apex finish method to schedule another batch job with scope of 100 due to callout limit

The schedule_batch_mdm_role_definition I believe is working fine. global class schedule_batch_mdm_role_definition implements schedulable { global void execute(SchedulableContext sc) ...
1
vote
1answer
19 views

Please provide your suggestion to Setup Alerts due to Integration failures

I have a use case to trigger an Email to Support Agents - Whenever record status is not moved from 'x' to 'y' within 1 hour. whenever record status is set to 'x' - SFDC will trigger an OBM(Out Bound ...
0
votes
1answer
14 views

Calling rest resource (Post) within the test class

I am working with a supplier who proscribes DML operations on its application's objects. Instead, they ask us to call Rest resources in our org that they developed in order to interact with the data. ...
0
votes
1answer
32 views

How to reduce the size of scope of this batch class

Due to a platform limitation that trigger on attachment won't be invoked when an attachment is sent via email I wrote a batch class to clone and parent email attachments from EmailMessage to a custom ...
0
votes
1answer
59 views

REQUEST_RUNNING_TOO_LONG

First error: [REQUEST_RUNNING_TOO_LONG] Your request was running for too long, and has been stopped. I was looking at What causes REQUEST_RUNNING_TOO_LONG test errors?. I was guessing because its a ...
0
votes
1answer
32 views

Email is not firing for feeditem records inserted through DataLoader

When I am Inserting feed item records through dataLoader, the standard salesforce chatter email is not firing. But When I insert a record through UI, I am getting the mail. Also, the email is coming ...
1
vote
2answers
26 views

Test Class for batch job, how to cover execute method

I am trying to write test class for a batch job, but I am not able to cover the execute method and to enter in it in order to debug my class. How can I cover this method? Batch job: /** * ...
0
votes
2answers
47 views

Rest callout via Batch Apex throws invalid session Id error

My Question is exactly same as this one - https://developer.salesforce.com/forums/?id=9060G0000005MLWQA2 But i will give more details. We just turned on Lightning Knowledge on in our environment, ...
0
votes
1answer
36 views

Batch Apex Chaining Limits

I have seen Apex Batch Job Chaining Limits, but my questions is little bit different so still wanted to confirm. I was looking to chain 3 batch classes. Below would be number of batch classes. ...
0
votes
0answers
20 views

Batch apex Stuck in Queue and never executes

We have a batch scheduled that runs early morning. It stays stuck in the queue and never executes. Is there any thing wrong in my code global class BatchAutoRefreshOpportunityRateDeck implements ...
1
vote
2answers
161 views

How to process more than 25 batches of 2000 records?

I am trying to chunk the results of a query of mine, but I am noticing the batches stop after 50,000 records (25 batches of 2000 records). I read iterable has a limit of 50,000 but I thought that was ...
2
votes
0answers
19 views

Test.createStub for class which returns Batchable in method

I believe I've found a bug, but I wanted to throw it to the community to see if I'm not understanding something. I'm implementing a test class and using Test.createStub to mock a dependency. The ...
0
votes
1answer
58 views

Need help with System.LimitException: Apex CPU time limit exceeded

I am receiving the following error, when trying to bulk load the customer records. Some of them are uploaded successfully, while some of them are throwing the following error. <message> ...
0
votes
2answers
61 views

Get Set ID from List in Batch Class

The ws_contact_callout class expects a SET of ids. in the Execute methods I attempt to get it but within the loop but the compiler is complaining. How can/should I get the Set of ids without requery?...
0
votes
0answers
48 views

Update most recent (newest) Opportunity with Created Date to Stage ' Closed Won'

I am working on a requirement which goes like something bleow: We have Accounts and Opportunities. Opportunities has a record type as Surgery. If the account has more then one suregery opportunity, ...
0
votes
2answers
23 views

How do I iterate over my Set in a Batch Class?

I'm trying to iterate over a Set that is sent to my Batch Class, I am getting an error stating the following: Class FileCleanup must implement the method: void Database.Batchable.execute(Database....
0
votes
1answer
24 views

Default CreatedBy/ModifiedBy user for the records created by a Batch Class?

I am just wondering, which Salesforce Admin user will be the CreatedBy/Modified for the records that are upserted in a batch class? Is there a special setting where I can see/modify/choose a specific ...
0
votes
0answers
20 views

First error: ContentPublication Limit exceeded [duplicate]

I am receiving the above error upon executing anonymous code of a test class. All I am executing is database insert of 200 records each time (total 14000 records). The primary aim is to insert all the ...
0
votes
0answers
29 views

Batch Apex Test Class not covering exectuable

I have the following Batch Apex Class, that looks for all Accounts where 'Data_Reminder_to_be_sent__c = true' and updates a checkbox on the account accordingly: global class SendDRSEmailBatch ...
0
votes
1answer
28 views

Need help on how to cover this query filter criteria in batch apex test class

global class BatchUpdateEnrollmentState implements Database.Batchable < sObject > , Database.AllowsCallouts, Database.Stateful { public String query; global Database....
0
votes
1answer
27 views

How to execute batch based on records refresh?

Requirement: Here I have Contacts, each of them is may/may not self-related to another Contact. Terminology: Primary Contact and Secondary Contact. Here Primary Contact is a self lookup field on the ...
1
vote
1answer
28 views

Is it necessary to create separate test classes for a Schedulable Class that triggers a Batch Class?

I have a Batch Class global class UpdateAssetInstallStatus implements Database.Batchable<sObject> { global Integer assetsProcessed = 0; global Database.QueryLocator start(Database....
-1
votes
1answer
36 views

unable to cover batch class completely [closed]

Scheduler Class: global class bankerjob implements Database.batchable<sObject> , Database.Stateful{ private EmailTemplate emailTemp; global bankerjob(){ emailTemp = [Select Id From ...
1
vote
1answer
137 views

First error: Exceeded maximum time allotted for callout (120000 ms)

I have a Batch class making an API callout and I have scheduled this class. I have used a for loop to iterate through the page number variable in my API endpoint. There are 64 pages. Strangely, if I ...
2
votes
0answers
59 views

Scheduler test class fails while packaging

Scheduler Class: global with sharing class Demo_Scheduler implements Schedulable { global void execute(SchedulableContext sc) { Database.executeBatch( new Demo_Batch(new List&...
0
votes
1answer
32 views

Help updating record's field with lookup's child record

I have three objects: Order__c Package__c Account Package has a relationship with account and order. Order has a relationship with account. If a package has an account attached to it, how can I ...
0
votes
1answer
34 views

Constructor not defined executeBatch trigger to pass ID to batch class

Ok...trying to write my first class and trigger and running into a wall that I can't seem to get over on my own. Use case: on a custom object called manufacturer__c, when a field goes to "in Process" ...