The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
26 views

Ending position out of bounds: 10

I am trying to get the first 10 characters from "Patient_Name__c" field into the "Patient_Id_Help__c" field but when i run the batch class it is throwing the error as "Ending position out of bounds: ...
1
vote
1answer
36 views

Receive scope to batch from a function, without a query?

I need to update a huge amount of records, that are being updated by an integration. i have the following code: private void populateRelatedAssetsFields() { System.debug('LicenseTriggerHandler....
0
votes
0answers
34 views

How to design solution for querying 200k+ records and using that inside LWC?

I have a problem statement where I need to design an LWC component to enter policy information and check if that policy already exists in the system and print a report of those that aren't in the ...
0
votes
1answer
18 views

Queueable apex duration time issue

I'm running a Queueable that upsert contacts (in my example case it's just two contacts) and calling a batch with a Map < Id,String > - which Id is the Id of the upserted contacts, and the String ...
1
vote
2answers
118 views

How many records can an Apex Batch process

Finding mixed results within web searches, trying to locate a concise answer as to how many records can a batch process. I am creating an apex batch that will run daily. It will query around 55,000 ...
0
votes
1answer
26 views

Is there a problem to send Map<Id,String> to batch?

I'm trying to send Map to Batch From Queueable apex Map < Id, String > conList = Insert_Update_Contact(data.Students, countryMap, citiesMap); System.debug('conList -> ' + conList); //...
1
vote
1answer
44 views

Run a batch after callout is finish

My process - I have a process in which I send data to outer system - and get a JSON to insert into Salesforce. This is handled by a scheduled class once a week. The Received JSON: - (Could be ~7K ...
0
votes
0answers
16 views

how to restrict visibility of text field rows of values based on user's accountshare on a single record

I have requirement to create an alert everyday displaying list of calls submitted by users sharing same set of accounts over last 7 days. But the text field should display selective values for user ...
0
votes
0answers
26 views

Apex class creating multiple opportunities for each contact

I am working on one apex class which needs to create or update opportunity for a Contact. if no opportunity exists then I am creating Opportunity else I will update opportunity. but the issue here is ...
0
votes
0answers
21 views

Test.setMock working in Scratch org but not in sandbox Org

We have batch class used to make an API callout and doing Opportunity upsert DML operation in the Start method. Based on the opportunity's return value, we are making another API callout and doing ...
0
votes
0answers
36 views

Batch apex to insert or update records

Can anyone help me out in writing batch apex which will insert or update records to another object based on some condition. I have two objects 1) SIS_Staging__c 2) Contact Both objects are having ...
2
votes
1answer
78 views

How to use batch apex job to handle a list read from json string

I am planning to insert a bunch of sobjects into Salesforce coming from json string (various objects and need to query existing information so data loader won't apply) . How can I use batch job to ...
-2
votes
2answers
30 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
38 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
16 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
2answers
43 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
48 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
34 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
53 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
21 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'...
-2
votes
1answer
35 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 ...
7
votes
1answer
56 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
48 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
37 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
43 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
36 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
62 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
36 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
59 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
27 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
42 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
29 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
35 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
60 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
37 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
57 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
88 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
79 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
22 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
37 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
41 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
40 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
32 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
81 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
49 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
63 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){ ...