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

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.

0
votes
1answer
38 views

Callout from scheduled Apex not supported: Retrieving token

I have a scheduled batch class that updates my order payments however I am receiving an error that the callout is not supported. I have read other posts that for batch classes if Database....
5
votes
2answers
167 views

Enforce Batches (whole run, not single jobs) to wait for each other

A few situations in my app trigger a Clean up batch to run. It will process many records. In some situations multiple of such Cleanup batches will be triggered by independent user operations. If the ...
0
votes
2answers
38 views

Batch-safe Apex

In Java, there is such a concept as writing thread-safe code, in order to avoid things like deadlock, race condition, stale field values, etc. In Apex, is there a similar concept of writing Batch-...
0
votes
0answers
17 views

Apex class to check for Process instance steps (related to custom object), with the status pending and delayed for approval for more than 24hrs

Batch Apex Class on custom object containing approval process, to send an email to the approvers logged into the approval history related history of the custom object records , If at all the approval ...
0
votes
1answer
33 views

test class with Batch and Callout [duplicate]

I have a problem with FeedItems in my Test class, it's very weird behaviour Does someone explain to me why this happens? Callout Class public with sharing class Callout { public static void ...
0
votes
1answer
20 views

Batch Adding Compile Error

I'm trying to create a list from a custom object (InvoiceAccount) and with a key of AccountID, get all the related Contacts and insert fields from both of them into another Custom object (...
0
votes
0answers
25 views

Batch queries against standard and custom objects

I'm executing batch queries against a standard object (Account) and a custom object (InvoiceAccount). The query against the standard objects compiles and executes. The one against the custom object ...
2
votes
1answer
29 views

Why Would Batchable Not Run the Specified Scope Limit?

I call to a batch class on 204 records: PaymentAgreementMonitor myBatchObject = new PaymentAgreementMonitor(); Id batchId = Database.executeBatch(myBatchObject, 66); When it runs, it is running on ...
-1
votes
2answers
29 views

i want to create batch process for project that if 2 task are at risk status project stage should at risk value [on hold]

global class mybatch implements Database.Batchable <sObject> { global database.QueryLocator start(databatchableContext bc){ return Database.getQueryLocator([select id,status__c,(...
1
vote
2answers
56 views

Query Limit on Batchable Class

What is the best practice with governor limits with Batchable classes and queries inside of the Batchable class? I am running into query limits with a Batchable class because I have too many ...
-1
votes
0answers
20 views

Failing batch class daily in prod [closed]

I wrote a batch class which updating records. as per batch query it is returning 70 records .. but it is failing every time in production with this in prod also 70 record with batch query condition ...
0
votes
3answers
35 views

Test Coverage in Select DML Exception

How can we throw DML exceptions in Batch Start method in apex? I want to cover a code using test class which handles dml exception in select query in batch start method. Query is simple select query ...
0
votes
1answer
17 views

Executing Function with Batch Execute Class

I am attempting to refresh an account list that I utilize within the execute function of a batch class. I am trying to do this by wrapping the query in a function. My purpose in doing this is so I do ...
0
votes
1answer
21 views

Delete last 30 days data using batch class not working

i have been trying to delete last 30 days records through batch class, i am not getting any errors. i don't see my records were not deleted while i run the batch job, please advice. thanks in advance.....
6
votes
2answers
187 views

Is this test for callout wrong? How to make a bulk?

I wrote mock and test for callout, but I don't think it's right. I think I check wrong things with asserts and maybe call the same methods a few times, while have another ways to get 100%. Have I? I ...
0
votes
1answer
26 views

Trying to get session id in a batch/queueable apex [duplicate]

I have tried both the below approaches, but still I see only "SESSION_ID_REMOVED" in the debug statements. When I schedule the batch from Developer console, I am getting the "SESSION_ID_REMOVED" in ...
1
vote
1answer
37 views

Duplicate batch is not working as the original one

I have created a chain of batch classes (5 batch classes calling each other) and everything working as expected. After this is deployed in production, to do a real time testing and debugging for ...
0
votes
1answer
38 views

Batch Apex ignores records even without subquery in start()

Basically the querylocator returns about 200000 records at the start, I can see it in logs, also there are not any errors or limits warnings. The size of each job matters because the smaller it is,...
1
vote
1answer
41 views

Batch Test Class works in Production, Fails in Test

I've started a new job and the test code coverage here is poor. I am working to improve this and one of the batch classes has coverage of 77% in production. This is now below the org % so I thought I'...
0
votes
1answer
29 views

Unable to get the non duplicate Contact Emails from Child records

I have a lookup relationship between Order Line and Contact Objects where Contact is the parent. I am writing a batch class which looks for certain criteria on Order Line and send email to Contacts ...
0
votes
1answer
18 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....
-2
votes
1answer
34 views

Cover execute method of a Batch class

first of all thank you for your time, i need some help to cover this batch class, right now the test class i will post bellow only covers the finish method and the get; set; . CLASS: global class ...
0
votes
1answer
34 views

Limits of Batch, REST API: how to get 2000+ records, not just 250?

This code works, but I can get only 250 records even if on other side 2000+ records. I think my batch is incorrect. How can I make a few callouts per 1 time to get 2000+ records from service side? ...
0
votes
2answers
27 views

What's wrong with my Batch Apex + Http callout get method?

I think my code is wrong. Last version of my HttpGet/Callout code (it works): How to use HttpGet service to get a list of objects and create them? Now I try to make it batch. My Execute Anonymous ...
0
votes
1answer
16 views

Batch Scheduler Error

I have Created a batch scheduler which need to run for Every 5 min. but i am getting this error. can any one please help me out. Error: Compile Error: Method does not exist or incorrect signature: ...
0
votes
0answers
24 views

Batch APEX CSV Reader

I'm trying to implement a batch process that will read a fairly large csv, and import the files into the Account Object. To do this, I'm referencing https://developer.financialforce.com/...
1
vote
1answer
107 views

First error: Query of LOB fields caused heap usage to exceed limit

I simply try to execute a batch job and execute a SOQL inside the execute() method as below with having, execute() method has the line List results = (List)database.query(query); , and start() ...
0
votes
1answer
24 views

how to write 2 queries in the start method of batch class based on condition

how to write 2 queries in the start method of batch class based on the condition select id,name,email from Account where createddate=today select accountid,Account.name from Contact where account....
1
vote
0answers
25 views

Batch Apex updating 300,000 records and returning errors in CSV and sending as Email

I have to update 300,000 records using Apex Batch. I also have to send an email to the user with the CSV file containing errors from update operation.Assuming all 300,000 records give failure, if I ...
1
vote
0answers
19 views

how to check iterator in batch process

I am using an iterator to use an aggregate query on a custom object looking for unique years. on the very last iteration, I want to change a value, so I am hoping to use hasNext, but it looks like i ...
0
votes
1answer
31 views

Optimal number of records per batch

I have a problem executing a batch in some limit cases that i want to cover to avoid future concerns. The scenario is the following: My batch works on n(reasonable high number) records of the same ...
0
votes
1answer
20 views

Apex Batch Test Class Does not seem to be executing the Execute Statement

Based on the posts I read it seems like the consensus is the test record is not being created but I believe it has enough to create. The execute part of the class never seems to fire. The actual ...
1
vote
1answer
27 views

AsyncApexJob record when I use System.scheduleBatch() method

I have just found a very strange behavior regarding Batch. If I have a Batch and run it using the method Database.executeBatch(), a new record inside AsyncApexJob table is created and I can use ...
1
vote
1answer
34 views

Insufficient Code Coverage for Batch Class

global class EmailNotificationBatch implements Database.batchable<sObject>,Schedulable,Database.Stateful { /* Getting data from the account */ global Database.QueryLocator start(...
1
vote
1answer
18 views

Issue with batch which is scheduled for every 5 minutes and didn't run for 24 hours and 5 minutes

we have batch which is scheduled to run every 5 minutes. This batch was working well for few months and then on 7th of November it didn't run for 24 hours and 5 minutes. After that, it is running ...
0
votes
1answer
27 views

Can we schedule a apex class at a time in different time zones

We have a batch class to updates events dates. But all the users are not in same time zone.Some users are in Uk,Some are in USA,Some are in India..etc My batch class will run every day at 1 am of ...
0
votes
2answers
25 views

Testing Outbound Messages via Apex

I'm trying to write a unit test to check whether or not an outbound message was triggered via a workflow. For instance, I have a class that will set a field on a contact record. The workflow rule is ...
0
votes
2answers
29 views

Batch Apex Limits in a trigger

In the trailhead lesson "Use Batch Apex" the final line states: Use extreme care if you are planning to invoke a batch job from a trigger. You must be able to guarantee that the trigger won't add ...
1
vote
1answer
25 views

How to change concurrencyMode Apex batch

The documentation (Unable to lock row - Record currently unavailable errors ) says to change 'concurrencyMode' to Serial instead of Parallel. But I can't find how to change this property in apex ...
1
vote
1answer
47 views

How to stop 'Database.executeBatch cannot be called from a batch start, batch execute, or future method.' error

I need to run Account Assignment rules after Account is saved to DB and update Account owner and add Account team members later. During batch update, it's erroring which is logical. How can I fix it? ...
2
votes
1answer
46 views

50,000 Row Limit

I have a method that gets a count of contacts associated with a custom object Region__c and then gets a count of the tasks assigned to those contacts. If I run an update in Data Loader on Region__c I ...
1
vote
1answer
31 views

Why did some batches execute successfully despite the Report REST API Limit?

BACKGROUND We have a legacy batch process that selects all contacts and runs a report for each account. Below is a simplified example of that class (all the necessary details are preserved): ...
0
votes
1answer
25 views

Queued batch jobs limit

I am confused by the asynchronous Apex limits. The limit for number of batch jobs in the flex queue is 100, but the max number for batch jobs queued or active concurrently is 5. So my question is ...
-4
votes
2answers
30 views

Running apex batch from controller with parameter [closed]

This is my controller. public class vfcontroller { public Date startdate{get;set;} public Date enddate{get;set;} public PageReference submit() { System.debug('@@@1'+startdate); ...
1
vote
0answers
47 views

Bulkify dynamic query Batch Class?

I converted existing batch class that was processing single record into schedule/batch class that can process multiple records. But I got stuck in bulkifying the dynamic SOQL inside the for loop. ...
1
vote
1answer
70 views

Batch Apex Too many SOQL queries: 201

I am getting Batch Apex Too many SOQL queries: 201 when the class is scheduled for run in developer console. Batch Apex: global class Batch_EmailBlast implements Schedulable,Database.Batchable<...
0
votes
2answers
47 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
42 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
54 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
16 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 ...