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
1
vote
1answer
19 views

Create custom method in Apex batch class and make calls to it from execute method

I am trying to call a custom method called addColdCustomerToList from execute method, is that something that can be done inside a batch class. global Database.QueryLocator start(Database....
0
votes
1answer
19 views

Platform Events - Fire platform event from event trigger?

We are planning to build some kind of a processing chain, when every item in an array is processed in separate scope of limits. Processing should happen strictly in a sequential way, i.e. second item ...
0
votes
0answers
11 views

Fetch Record ID from batch job id

I have a job id for a batch apex class.I need to fetch the record ids from the job id.Is it possible to use an SOQL to fetch the record id for which the particular job id ran. I need help on the query ...
0
votes
1answer
15 views

Error in batch class - not getting the correct time

Getting error in the following lines: if(Datetime.now().hourgmt() == 16){ ev.StartDateTime = Datetime.valueOf(Datetime.now().hourgmt()+24); }else{ ...
0
votes
1answer
21 views

how to refer a record type in a apex class [duplicate]

I'm writing a Apex class to auto delete Case records of record type claims and service failure with created date older than 6 Years here is the code. But i'm failing to Refer the record type in the ...
0
votes
1answer
23 views

You have uncommitted work pending. Please commit or rollback before calling out. Apex Batch

I have a little problem with my batch: List<String> idList; public My_Batch(List<String> ocIdList) { idList= ocIdList; } global Database.QueryLocator start(Database.BatchableContext ...
-2
votes
0answers
21 views

Getting following error [closed]

First error: Invalid integer: java.util.GregorianCalendar[time=-3,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,...
0
votes
0answers
24 views

how to handle platform events from flow when received as a batch at once

I am creating a flow that uses an Apex action that calls multiple future methods in quick succession and publishes platform events for each of them when they are done. There is also another flow with ...
-3
votes
2answers
61 views

Email Attachment using batch class [closed]

I have a batch class which will send a mail to contact owner with the Custom Email Template as attachment. Even though it doesn't have any error the batch class was not running. Can someone help me to ...
0
votes
0answers
27 views

Alternative of Batch calling Future method

I've looked around to try to find some posts on this and there are many but none that address my specific question (that I could find). I am trying to call a @Future method inside a for loop in my ...
2
votes
0answers
34 views

order of records received in batches for batch class

I have a batch class where i need to grab the records sequentially. It looks like if i am querying regularly in salesforce and system.debugging the outputs, the records do not seem to be in any ...
0
votes
1answer
44 views

Batch apex class not querying through all records

The below code runs 57 batches out of 98 and then says the below message: global class MDUSquadRawDataBatchTest implements Database.Batchable<sObject>, Database.Stateful { List<...
0
votes
1answer
27 views

apex which populates Account Record Type info into “MC Commercial Setup” field for all existing customers. This job will be run only once [closed]

For Account, we have some record types defined like 'small organisation', 'large organisation', 'business' etc. There are 2 millions records. Requirement: I need to update custom field ...
0
votes
1answer
25 views

Relationship query not returning any records

I have a batch class, in that I'm doing a dynamic relationship query my code is as follows global class RBS_DeleteScheduleBillRunBatch implements Database.Batchable<sObject>{ global String ...
0
votes
1answer
16 views

How to start bach proces from anonymouse window

I Have the following batch process. How do I test this from an anonymous window? global class Batchtest implements Database.Batchable<SObject>{ .. }
0
votes
1answer
29 views

Are queuable jobs given precendence over batch jobs

I am trying to move my vf page controller logic to queueable job to over come cpu time out. I am monitoring the queueable job by polling the server from my vf page and then redirecting the user to a ...
0
votes
1answer
17 views

Unable to call opportunity name from list

I have a Batch Class where it sends an email when Expiry Date (Custom Date Field) is today. The mail body contains the list of opportunities whose Expiry Date is Today. I have created a list and added ...
-2
votes
1answer
17 views

How to filter records on boolean field in Batch apex

Fields are as follows:- Assistantname which is text Level__c is a picklist field prestigious_contact__c is a boolean field When I run this query I keep getting Unexpected Token :-'&&' error ...
0
votes
1answer
18 views

Batch class giving not working as expected

I have a requirement where i need to update amount pipeline field in accounnt object for the newly created account the value need to be come from sum of opportunities associated with that particular ...
0
votes
1answer
24 views

Batch Class is not running properly

I have a batch class that will send mail if Opportunity Expiry Date (Custom Field) is Today. I have tried a batch class but it isn't working for me. Can someone tell me how to achieve this. //Batch ...
0
votes
1answer
34 views

A Batch class for trigger? Or there is another solution?

I have a trigger for many records. In my unit test there is no problems with 1500 records. But I'm getting the 'Apex CPU time limit exceeded' error with 1800 and more records. Is Batch the only ...
0
votes
2answers
43 views

Illegal assignment from Decimal to Integer error

I am getting Illegal assignment from Decimal to Integer error for the code Integer maxEmailsSentPerDay = tpfs.Maximum_Emails_Per_Day__c; where Maximum_Emails_Per_Day__c is a number(18,0) field ...
0
votes
0answers
21 views

Database.Upsert operation says field doesn't exist, when it exists

I have a custom object named MDU_Squad to which I insert records using the Data Import Wizard. I have set 2 external ID fields in there, which are Street_address [duplicates allowed] CIty_Name [...
1
vote
1answer
36 views

Batch - too many SOQL Queries 201

I'm trying to get a count of how many placements are on an account. If the record type is subcontract, I want the query to look at the subcontract field on the placement and if the account record type ...
0
votes
0answers
21 views

How to delete ContentDocument records which is associated with its Parent record , based on Parent Field value?

Parent Object: ccrz__E_OrderShipment__c Field: Status: Cancelled / completed /Process Currently we are deleting the attachment (Doc) which is 180 days old. Now we need to add one more condition that ...
0
votes
1answer
21 views

Class BatchTest must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>)

global class BatchTest implements Database.Batchable<SObject>{ global Integer recordsProcessed = 0; global Database.QueryLocator start(Database.BatchableContext BC){ return ...
0
votes
1answer
17 views

Passing a second parameter to batch process

I have the following block of code that is working. However, I need to pass an additional field that will be used in the FINISH block to save a custom metadata value for the next time the process ...
1
vote
1answer
41 views

Throw a DML exceptions in Apex Batch Class for testing

Below is my batch apex class that updates Account object for example: global class abc implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext ...
-2
votes
1answer
37 views

Question regarding batch apex salesfroce

I am updating the contact information based on another object activity by comparing the contactid of the value. if the activity having multiple records i want to update the contact with recent ...
1
vote
2answers
95 views

Managed package batch failing to execute with error CPU time limit exceeded

I am trying to understand why managed package batch is failing. From the below screenshot, can we assume that it failed in the start method itself? or entered first iteration of execute method and ...
1
vote
1answer
59 views

Execute method within batch APEX not firing from test class

I have written the following batch apex class and corresponding test class. Tests are successful but the execute method is never called. I have attempted to debug to try to pinpoint the problem but ...
0
votes
2answers
35 views

Passing method parameter to the start method of batch class

I have a below batch class where I am passing 100 account ids to the constructor and in the debug logs I can see 100 in constructor as a set size but in start method I can see 0, could someone please ...
1
vote
0answers
30 views

How can I work with both QueryLocator and List<SObject> in a single batch class (not a single instance)?

I've been working on a chainable batch class. The constructor can take in either a service & query or a service & list of records. In almost all cases, the service/query are passed in. In ...
1
vote
1answer
35 views

Finish method of batch class is not invoked when error occurs

I have a batch class that http callout in the start method. Also, wrote an some block of codes to send notification when something went wrong in the finish method. However, when api return ...
0
votes
1answer
38 views

DML in @Future called from Trigger in Batch

I have a after insert trigger on an object that calls a @future method to do a callout to an external system. If the callout fails I want it to update the original object. I am batching up 100 at a ...
1
vote
1answer
59 views

Batch->Queueable->Callout+DML ::: Uncommited work pending issue

I am having following structure, where I am getting issue- CalloutException: Uncommited work pending. Ideally, with Queueable it should not throw the same error(since DML is happening at last in ...
1
vote
1answer
35 views

Can i improve code coverage for loop in batch apex

Firstly I wanna protect my organization code coverage, My scenario is as follows; I wrote 1 batch apex process, for calculate cycleTime to every products, am getting %80 covarage with this code but ...
1
vote
0answers
32 views

How does flow accept input parameters from batch class

I have an apex trigger and a batch class. I am running apex trigger on contact, sending it to batch class and from batch class sending the parameters to flow. Trigger: trigger BulkContactsLoad on ...
2
votes
1answer
137 views

Is there any way to extract more than 50k records inside execute method of batch?

I have a batch working on approx 40k records in chunks of 200 records. Inside execute of the batch I am querying from one abject returning more than 50k records. Getting 500001 error. How to remove ...
0
votes
1answer
29 views

Batch class for insert and update

I need to write batch class for inserting records to one standard object(case) to custome object. also if any record get updated, then it should also get updated in custom object also. i wrote below ...
0
votes
1answer
25 views

Apex Batch slow

I've launched an apex batch but each processed batch is too slow. Looking at the duration of each execute method, I see that the duration is around 2.668 ms but the next execute method is processed ...
1
vote
1answer
75 views

How to force future method to wait until current thread finish?

I have an apex code which is called from an after trigger. The apex code calls a future method and sometimes the future method runs after the execution of the current thread and sometimes does not. I ...
0
votes
1answer
40 views

Custom Roll Up Summary - Batch Apex/Trigger/etc

I want to make a roll-up summary-like field between two objects with a lookup relationship. The relationship can't be changed into master-detail so I'm writing some custom code to do this. Since it ...
0
votes
0answers
18 views

Query for Contacts on Accounts in Execute Part of Batch [duplicate]

List<Account> Scope = [SELECT id FROM ACCOUNT]; // This is the query being used global void execute(Database.BatchableContext BC, List<Account> scope) { List<Account>...
0
votes
0answers
21 views

Test class for batch apex with email message [duplicate]

global class Email_payment implements Database.Batchable<Sobject>,database.stateful { string email; List<Contact>emailids=new List<Contact>(); global Database....
0
votes
1answer
29 views

Update related record with batch class

I'm running a batch class over the Timesheet object and for the timesheets that meet the criteria, I want to update the related Contact record. I have a jstcl__TG_Timesheet__c object with a field ...
2
votes
0answers
60 views

“LimitException: Batchable instance is too big” when scheduled batch runs at night

Note: This is not a duplicate of the other similar questions. We checked them before. So please don't close this as a duplicate! When calling this batch class in a production org: global class ...
0
votes
1answer
33 views

Callout from batch issue

@RestResource(urlMapping='/UsageInputDemo/') global class APTS_UsageInputWSDemo{ @HttpPost global static void loadUsageInputsDemo() { RestRequest req =RestContext.request; Blob body = req....
1
vote
1answer
29 views

Clone Data of big Object into another big Object

I have roughly 10 million records in Big Object and now I need to move the data/clone the records in another big Object. The reason why I am doing this is that I need to modify/add more fields to the ...
1
vote
0answers
49 views

Testing Batch Apex with Big Objects

I have a batch apex class that uses Big Objects for processing. However, when running tests on this batch class, Salesforce throws an error not allowing Big Objects to be inserted for testing: https:/...

1
2 3 4 5
31