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
-2
votes
2answers
24 views

what is the parameter database.batchablecontext?

I was learning batch apex and it has three method which is start,execute and finish. Each method has a parameter Database.BatchableContext. What is this parameter and why it is being used in all ...
0
votes
1answer
28 views

Constructor Syntax in Batch Class

I'm new to the development side with no real development background in any language. So I wrote this batch class, and I can't quite figure out how to implement the proper syntax for the constructor. ...
0
votes
0answers
13 views

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY FUTURE METHOD [duplicate]

I have a trigger on the account object which makes a future callout. I want to cause this trigger to fire on all account records to make the callout. My thinking was I could do this via a batch class ...
0
votes
1answer
36 views

How to implement Apex Batchable properly, need to update ~5M records

I need to update CampaignMember, the value that I need to insert is in Opportunities, but there are more than 4 Million records, I was using Jitterbit and Excel to do this, but is very difficult ...
0
votes
2answers
41 views

Does Database.Update(records, false) roll back the failed records?

If I call Database.update(records, false); will only the failed records be rolled back or will there be no rollback whatsoever? Imagine this scenario, record is updated, kicks of an insert (inside ...
0
votes
1answer
30 views

Most robust way to parse CSV file via Apex code

I have been tasked to create a batch apex loader which parses a CSV file from an email attachment. I will use an email handler to get the email with the CSV file attached, and then I will try to load ...
0
votes
2answers
42 views

Unable to insert the records in my custom object using batch Apex

Thanks in advance. I have a batch apex code here. I want to insert the records into my custom object. what is the code for inserting the records. global class WeatherForecastBatch implements Database....
0
votes
0answers
19 views

Error deserializing response when iterating over a list in a batch

I'm doing a batch to send objects to an external web service. The class method that does the http requests receives a list and iterates in a for each, sending each record in one callout by record. I'...
-1
votes
0answers
28 views

I have a Weather Forecast object. I want to insert the records to custom object. there is no error in my code. but the records is not inserted

global class WeatherBatch implements Database.Batchable<sObject>,Database.AllowsCallouts,Database.Stateful{ public List<Weather_Forecast__c> listWeatherForecast {get;set;} public ...
-2
votes
1answer
34 views

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

global class WeatherBatch implements Database.Batchable<sObject>,Database.AllowsCallouts{ String query; global Database.querylocator start(Database.BatchableContext BC){ return ...
5
votes
1answer
46 views

Reason not to implement Database.AllowsCallouts

I have a number of batches all extending a base batch class that handles logging of sorts. Some of these batches do callouts, while others just handle data in Salesforce alone. It happened to me on ...
0
votes
0answers
14 views

Test Class Failing for a Batch Apex Class [duplicate]

I have created a test class which tests the code for a batch apex class but the code coverage is only 62%. I'm really stuck and don't know how to get over it. I'm new to salesforce and any help would ...
0
votes
2answers
45 views

test class for batch apex not covering execute method

I have written a batch class for cloning the opportunity and updating the stage field. Class is working fine. But test class is not covering the execute method. Logically I felt the test class is ...
0
votes
1answer
35 views

How to deep clone a batch class?

I have tried deep cloning on the opportunity object which has closed won stages it will also clone the Related Products I have tried cloning the opportunity and it works okay,how will i deep clone it?...
0
votes
0answers
34 views

Batch Apex Class quey

I am new to Salesforce and Apex language. So I have a use-case where I have to first make two custom objects named Aggregate Book of Records with fields year(type picklist with values from 2019-2025),...
2
votes
0answers
39 views

Apex Batch Test - works if I populate only one account, fails in setup with 2 accounts

I have written my first Apex batch processing class. It works when I manually create records and run it in my sandbox. It is very simple. We've added a set of fields that can have up to 3 values: '...
1
vote
1answer
34 views

How do I find the Mode of a List in Apex

(Mode = the value that occurs most frequently in a given set of data.) I have a Lookup field on Contacts which lists the Contact's Specialty. I'd like to find the mode of the Specialties of all ...
0
votes
2answers
46 views

Aggregate query with filter in batch

I would like to use aggregate query in batch job but I'm running into an error: HAVING expression must be grouped or aggregated Would also like to understand how can I use count from the query ...
0
votes
1answer
35 views

Is there any way to define more than 1 SOQL quires in a batchable class start method

I have run into a case where i have to do same operation via batch over records in same object. But i cannot construct a query which can retrieve all of those records. Is there is way to achieve it ...
0
votes
0answers
29 views

Email not sent from Partial Sandbox using Batch

I have a simple batch job that is used to send a notification email. I'm testing in a partial sandbox, but the email is not coming thru. Here is what I've checked: I verified that deliverability is ...
0
votes
1answer
50 views

Batch Test class not calling execute method [duplicate]

I have created below batch apex class. I have also created test class for this. But this test class is only covering 27% of batch apex class. Also, it is not calling execute method of batch apex class....
-3
votes
1answer
23 views

Records are not displaying immediately,It needs to refresh page again.How can I display records without refreshing page?

I'm trying to display records in panel2 after clicking a button in panel 1.But records are not displaying immediately after clicking a button.Initially panel2 displays empty,after refreshing page ...
1
vote
1answer
41 views

Total number of batches in a job is different in UI and SOQL

Total Batches shown for a job in the APex Jobs page is different from TotalJobItems value in AsyncApexJob query. In the UI: In the Query: In the query result, TotalJobItems != JobItemsProcessed + ...
1
vote
0answers
25 views

Solution to stop getting “You've exceeded the limit of 100 jobs in the flex queue” for the batch class [closed]

I am sending records in batches to a batch class. Code: BatchClass myBatchObject = new BatchClass(Trigger.new); Id batchId = Database.executeBatch(myBatchObject); I am getting the flex queue limit ...
0
votes
1answer
34 views

How should we return direct soql query results from apex method to batch job?

How to return soql results to the batch job? Apex Method: public PageReference process(){ if(checkBoxVal==true){ VoucherGenerate_AssignBatch b = new ...
0
votes
1answer
58 views

Data doesn't display immediately after clicking a button.It takes manually refresh page again

I tried a lot to resolving this issue but not able to achieving the requirement.Please help me on this After Clicking a button in Panel 1,It navigates to Panel 2 and Initially it displays panel 2 as ...
0
votes
2answers
33 views

System.isScheduled() not working in Scheduler/Batch

I have a Scheduler class which executes a batch class. I also execute this batch class from a VF page. Deep down in the class hierarchy, I want to check if this batch was called from a Scheduler or a ...
3
votes
1answer
49 views

Notify Lightning Component when ApexBatch finishes

What is the best way to notify the Lightning Component when ApexBatch (invoked by LC action method) finishes? Use case - My LC is invoking ApexBatch to offload complex data processing. I want to let ...
0
votes
1answer
31 views

How to chain batch jobs when one is from a managed package

I have a scenario where users upload a file and a batch1 kicks off to create the records , once the records are created we pass on the ids we just created to another batch job (batch2) which is from a ...
2
votes
3answers
81 views

What method to use in a batch apex in order to get authentication token from a remote server?

I have a batch class that uses query locator to send data into the client's server. however, it must first authenticate and get access token and send that along with the data with all consecutive post ...
3
votes
1answer
77 views

Apex batch class test not running execute?

I have written a batch class to mark a certain number of an object in a date range to be marked for review, and it is working when called on from a visualforce page, but it does not work when called ...
0
votes
1answer
21 views

Custom Iterators - calculating scope - batch

I am trying to understand the custom iterators topic Custom Iterators But there is a thing which I don't get. There is a next() method which divides the query size into smaller ones, am I right? In ...
1
vote
2answers
31 views

Limit on Batch class

If I run a batch class every night, that goes over 10000 leads every night and updates a field. Would I get the limit exceeded error considering the huge number of records?
0
votes
0answers
40 views

!Set.contains returning true though it contained values

I have a Map value list that I am looking to check if it contained specific Id. I tried adding all map values to a set and the applying contains keyword. But either ways it returns false though I ...
0
votes
2answers
38 views

Making X amount of HTTP requests with a batch?

I would like to know what the optimal way of doing this in Salesforce is. Imagine the following scenario, I need to have batch as I need to make over 100 HTTP calls, The HTTP request would be sent to ...
0
votes
1answer
27 views

Schedulable Batch Apex class

global void execute(SchedulableContext cc) { BatchApexClass batchObject = new BatchApexClass(); Database.executeBatch(batchObject,10) ; } What is the meaning for 10 in the syntax "Database....
-2
votes
1answer
78 views

Sets contain duplicate values

Here is what I am doing. When I print the values of last set lssetlll, I see duplicates., I tried having a check to see if items are in the set and not add second time, but that is saying that the ...
0
votes
2answers
47 views

Migration Flow Too Many SOQL Queries

I created a one-time use flow for migration purposes. It looks up all the records to update, and calls a subflow to update each one. The subflow runs 8 or 10 queries and then updates one record. ...
0
votes
2answers
51 views

Failing Batch class : First error: List has no rows for assignment to SObject and running batch class with size 1

global class BatchForLatestCaseOHVRDatesAccountField implements Database.Batchable<sObject> { // Start Method global Database.QueryLocator start(Database.BatchableContext BC){ ...
0
votes
2answers
31 views

Adding time gap between two call of batches in test class

I had an issue in my batch class, it was picking the same data to process when it is already run for the same earlier. If the data is processed once, that batch should not pick that data again in the ...
0
votes
2answers
30 views

Way to limit total records processed by batch job (not batch size)

Is there any way other than modifying a query in the start method of an apex batch job ex: 'LIMIT 100' to control the amount of records processed by a batch. I know we can use Database....
2
votes
2answers
76 views

Can someone clarify when a Trigger executes on a single record vs. multiple in one context?

This may be a silly question, but I've been surprised by Salesforce enough to potentially look foolish for confirmation! Apologies, the question itself was difficult to phrase. Fundamentally, since a ...
0
votes
1answer
48 views

Invalid loop variable type expected Contact was ContactHistory

Here is my requirement: I have a batch class that I wanted to invoke when there is a change in the field of Contact. Basically I have 3 objects (Contacts, Items and Lists) When there is a change in ...
1
vote
1answer
22 views

Apex Batch Test Class for Opps with OLIs not returning values

I'm struggling with an Test Class for a little batch I created, let me clarify that I'm not a developer, so any tips will be appreciated. I wrote 2 versions of the class, the first gives me about 94% ...
7
votes
3answers
155 views

Is there a typesafe way to get a Database.QueryLocator?

Normally, to select things we use SOQL code like: [ SELECT Id, Blah1__c, Blah2__c, Blah3__c FROM Yada_Yada_Yada__c WHERE Id IN :idSet ]; When we do this, the compiler (and our IDEs) ...
1
vote
0answers
32 views

Testing Batchable with Callout Error: You have uncommitted work pending. Please commit or rollback before calling out [duplicate]

I have a Batchable class which does a callout. When I test the class which like this: Test.startTest() MyBatchableJob job = new MyBatchableJob(); Database.executeBatch(job, 50); Test.stopTest(); I ...
0
votes
0answers
14 views

VF Email template - send different bodies to same person

I have a batch which I use to send emails to contacts - the emails are Messages about courses - so Each Contact should have the same email template repeatable with a different body. So, I created a ...
1
vote
1answer
31 views

Not able to add more than 2000 records in excel file using batch class

I'm using the batch class to send an email with an attachment, but the issue is I'm able to add only 2000 records in single file. I have a huge amount of data so I'm getting multiple emails with ...
0
votes
1answer
64 views

How to call AsyncApexJob in test class from batch class finish method

here code is passed and code code coverage is not coverd, Please help me any one Test class test.startTest(); // UpdateOppToInitialize.UpdateOppToInitialize(); UpdateOppToInitialize obj = ...
-3
votes
1answer
38 views

Use of @testSetup method in a Batch Class [closed]

I have created a @testSetup method to create a data which generic. In my test method I am querying the data for some specific records and calling my batch class. The batch class is taking all the ...