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
1answer
20 views

Batch apex state is maintaining but records are not storing in global List from different Batches

In the below batch apex class I'm not able to store different batches or transaction records in the global list, I used database.stateful also still I don't know why?????? Currently I'm getting ...
0
votes
0answers
27 views

Execute batch from trigger if number of records in Trigger exceeds 10000?

Since we can't update more than 10,000 records in trigger in real time I was thinking of automating the update of the remaining records through a batch called from a trigger. So, Let's say for ...
0
votes
0answers
15 views

Test email sending in Batch class

I have created a batch that sends in email anytime the status of an article is updated. I am trying to write a test class for the batch but I only manage to cover 45% of the class. I struggle to cover ...
0
votes
0answers
24 views

test System field on Batch class

I have a batch that automatically archives any articles with a Status (Fixed) and published for more than 30 days (using a custom setting to verify the number of days). But I struggle to cover the ...
0
votes
1answer
39 views

How to know if there are any related task to the account?

I am trying to get the account where there is no task.AssignedTo = Account.OwnerId. I have written the logic. But it looks like I can get it more easily. How can I optimize my batch? Any help will be ...
1
vote
1answer
30 views

Behaviour of Batch Apex jobs when records modified during execution

I was wondering the following scenario - Consider in start method of batch Apex I query all the contacts which are having status = active - Let's assume it will return 50 million records Execute ...
0
votes
1answer
21 views

4 Schedule Statements using scheduler vs scheduling a batch from finish method for every 15 mins

I want to schedule a job every 15 mins, for now I have created a scheduler class and using 4 statements to schedule it, but then again there is no guarantee that a job might complete itself in 15 mins ...
-1
votes
1answer
22 views

How to fix System.NullPointerException: Attempt to de-reference a null object in a Batch

I have a batch and I can't figure out how to fix System.NullPointerException error going through my debug log my kes variable is null for (Known_Error_Subscription__c kes : scope) { kes....
0
votes
0answers
10 views

Why test class not covering the execute Database.batchable where I am deleting the list returned from the query locator? [duplicate]

global with sharing class JunkQueueBatchJob implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'select ...
1
vote
1answer
40 views

Calling batch class multiple times in a row

So, I have this method: @AuraEnabled public static string batchChangeItemStatus(Map<String, Map<String, Object>> filters, String status){ List<Item__c> items = getSearchedItems(...
0
votes
2answers
28 views

Reference Set<Id> in the WHERE clause of a Dynamic SOQL in Batch class

I have a Batch class and I am trying to reference a Set in the WHERE clause of a dynamic SOQL query but I have an error: System.QueryException: expecting a colon, found '{kA09E0000005mCySAI}' when ...
0
votes
2answers
34 views

Compare OldValue and NewValue in a Batch Class

I am trying to create a batch that send an Email anytime that status (Known_Error_Status__c) on a article is changed and the Article is 'Online' I have enable field history tracking on the object (...
0
votes
1answer
21 views

Use Batch to send email on Article status change

I am trying to create a batch to send an email anytime the status on a Knowledge Article (Knowledge__kav) is changed. The difficulty I have on this particular object (Knowledge__kav) is that anytime I ...
0
votes
1answer
15 views

schedule job using cron expression

How we can execute/schedule job every month's first week of saturday using cron expression. 0 0 13 * * ?
0
votes
1answer
18 views

Argument 1 cannot be null when I try to execute batch from test class [closed]

I tried to execute my batch from anonymous window, which is executing perfectly. But when I tried to execute from test class I am getting this error. I tried so many ways, but couldn't figure out what ...
0
votes
1answer
36 views

Getting error while executing

While i am going to execute this batch class in debug log then i am getting this error (First error: Too many query rows: 50001) in debug log instead of updating the records. global class ...
0
votes
1answer
37 views

How do I use batch apex for this?

I am trying to figure out how to use batch apex for an apex class like the one below. The first query itself returns over 50K records and thats throwing an error. I am also using a Map for that query ...
1
vote
1answer
33 views

Too many callouts 101 - External API and Paging through Results

I have a scheduled batch job that in the start method, I make a REST API call to an external service. The external API has around ~2000 total results to return, but the API only returns 10 records ...
-1
votes
0answers
27 views

Not able to create email body

I have two custom Objects - Buyer and Invoice (Lookup to Buyer). If Passport Number(Field in Buyer) matches with Account Passport Number(Custom Field) and having any Invoice records related to Buyer ...
0
votes
1answer
18 views

A callout in the for loop of a batch class's execute method is causing: You have uncommitted work pending

I have a scheduled batch, that takes all cases with field isFailed__c true in the start method: global class UpdateCases implements Database.Batchable<sObject>, Schedulable, Database....
0
votes
2answers
33 views

Hourly Batch job not running as expected

We want to run a Batch job that runs hourly and updates the users to Inactive if they are logged in last 2 Hours but not 30 Minutes. The Code works fine when I run it manually and but i need to run ...
0
votes
1answer
42 views

Database.Stateful in Batch gives errors

I have tried an aggregate query, but the result size is too large. So I built a new batch to run over the data and create an aggregation over Account and Product. Condition is that the Revenue/...
1
vote
0answers
19 views

How to interpret bulk API processing times

According to the docs apexProcessingTime is The number of milliseconds taken to process triggers and other processes related to the job data apiActiveProcessingTime is The number of milliseconds ...
1
vote
1answer
33 views

ISE when accessing methods on DMLException in batch context

I'm receiving an Internal Salesforce.com Error when attempting to access methods of a DMLException in a batch class. public class MyBatch implements Database.Batchable<SObject>, Database....
0
votes
0answers
10 views

Batch sequencing of data load tasks

Is there a way (easy?) to sequence the upsert of data across multiple objects using DataLoader or some other data load tool? As an illustration: I have to update the country field value for the ...
1
vote
1answer
35 views

How do I mock external objects for the purpose of testing a batch Apex class?

I have a Batchable Apex class that queries against an external object in the QueryLocator. I need to be able to write a test against the batch apex class to achieve coverage. I've looked this answer ...
0
votes
2answers
47 views

Luhn Algorithm: How to get check digit of MOD 10v1 in Batch Apex Class?

I would like to ask some help on how I can get the Mod 10 check digit of Contact.DonorID. the result should be Contact.CRN__c = Contact.DonorID + CheckDigit Just like this: Check Digit is 2 CRN: ...
0
votes
1answer
26 views

Code Coverage is passing in Sandbox with 84% but when deploying to prod its failing with 46% Code coverage

I'm deploying an apex class and Test class which is covering with 84% in Sandbox however when deploying in Production, its failing and says "Your code coverage is 46%. You need at least 75% ...
1
vote
2answers
64 views

How would I use Batch apex for over 10000 records?

I understand that I need to use batch apex to do something like this and I have used it before as well, but not in the right way. I ended up making a list using an soql query for all the records and ...
1
vote
2answers
68 views

When is Database.RaisesPlatformEvents needed on a Database.Batchable?

This Firing Platform Events from Batch Apex documentation largely discusses automatically publishing a BatchApexErrorEvent on an unhandled exception: If the start, execute, or finish method of a ...
0
votes
1answer
38 views

Issue with batch class soql query returning values

I am a newbie to salesforce development of batch classes query = 'SELECT Id,Auto_close_Date__c, Status, RecordType.DeveloperName, ' + Disable_Auto_Close__c, ' + ...
0
votes
1answer
21 views

How to query records processed between last batch job if I'm running batch class five times a day

I want to process only those records in my batch job which are updated since the last time my batch job ran. Basically, I'm running my batch job five times a day and want to process only those records ...
0
votes
1answer
17 views

Issue with Batch Apex Updating Results from AggregateResults SQOL Query

I have an object Referral__C where we add a NHC_Tracker_ID(Nhc_Tracker__C another object). I want to update the fields on NHC tracker by count Referrals and Unique addresses related to Referral. My ...
0
votes
2answers
46 views

Batch Apex to calculate rates based on more than 50k records

I would like to calculate rates based on sets of Opportunities returned from a query -- this query regularly returns way more than the 50k limit allowed. At a high level, I know that I can get around ...
0
votes
0answers
18 views

getting Internal Salesforce.com Error when fetching Query on ContentDocumentLInk

My rquriement is : i need to fetch all Files from Files Object . But Below my code, When i debug, getting Internal Salesforce.com Error. If i remove Files and then debug, This error is not coming . ...
0
votes
1answer
21 views

Expression cannot be assigned: when trying to use multiple if statements in a for loop

There is an object tm__c which contains LinkedIn URl(URL field),two picklist fields: Backgroundcheck(Yes, NO) and Verification(Pending, Not started, Done) I want to create a batch class so that I have ...
0
votes
0answers
26 views

Two Large Queries in Batch Apex returning at least 1lakh records each

I've two objects(Obj1 & Obj2), i will have to fetch the data in obj1. And based on the fields data in obj1, i've to query the data in Obj2. global Class batchapex1 implements Database.Batchable<...
1
vote
1answer
54 views

Dynamic Queries on Dynamic Objects at Volume

We are trying to create a mechanism that would process user dynamically created queries and create "Contributors" for each matching record. The object model is as follows: Account -< PO ...
0
votes
0answers
19 views

Debug Logs Cumulative Profiling not matching the actual debug logs

I have applied debug logs on a batch process and noticing some weird behaviour in Debug Logs. For some of the instances of debug log for execute method, I see that each method invocation to batch ...
0
votes
0answers
11 views

Visualforce component datatable duplicates rows

I have a batch class which sends out email alert first of every month. Batch class triggers the email alert using Messaging class which then uses Visualforce component to have the list of records in ...
0
votes
1answer
32 views

Why does a name change result in an invalid type?

I have two Apex classes that differ by literally only their name. Here's MaintenanceRequestBatch.cls: public with sharing class MaintenanceRequestBatch implements Database.Batchable<sObject>{ ...
0
votes
1answer
21 views

Auto Chunk Batch with BulkAPI

I'm trying to use Bulk API v1 to upsert massive Data using JSON. When I try to run the job via the standard bulk API, the next error shown up : InvalidBatch : Exceeded number of records: 10002. ...
-1
votes
1answer
24 views

Dynamic Variable Scheduler Class

I'm looking to pass a variable to my scheulder class when scheduling a batch job. The idea is that I'm scheduling the class multiple times, but passing in a different variable each time. Example: ...
-1
votes
3answers
57 views

batch apex opportunity records are not updating with compare of metadata records

Opportunity records fields compareing with custom metadata record and based on values match opportunity stagename will update but it is not working and gettin error in apex job also that duplicate id ...
0
votes
1answer
17 views

Batch Apex Error - Class must implement the following methods System.ScheduleableContext)

I am trying to update a batch class to allow me to schedule it, but I am getting this error: Class must implement the following methods System.ScheduleableContext I understand the error, but given my ...
0
votes
0answers
32 views

upsert Records using standard API and external Id

We want to give an external system the standard API to upsert records from Account Object with an external Id. The records have an associate parent Account that needs to be filled also with the same ...
3
votes
1answer
94 views

Can Database.executeBatch be called from a Queueable started by System.enqueueJob?

I'm aware that you can't call Database.executeBatch from the execute method of an already running Batchable. But can Database.executeBatch be called from a Queueable running via System.enqueueJob? I'm ...
0
votes
1answer
56 views

how to concatenate lookup fields given certain circumstances

I finished up this batch but came across an unforeseen scenario and can't seem to figure out how to code in the case it occurs. Here is my current code: global class Batch implements Database....
1
vote
1answer
29 views

confused while querying junction object

I am working on a batch and am writing a query but am getting confused because of the relationship... The batch is written on a junction object, Account_BOB__c, between 2 parents Account & ...
0
votes
0answers
37 views

Test Class of batch Apex which includes a Http Callout in the execute method

I'm stuck trying to create a Test class for my batch which execute a Http request. I tried with Test.setMock and also inserted "!Test.isRunningTest()" in the batch but nothing changes. I ...

1
2 3 4 5
35