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

Apex heap size too large Exception in - Batch

We have 2 objects : Order_Integration__c, Order. We are running the batch Copying order integration table data to order table. Requirement : If any error occurs while creating order. That respective ...
0
votes
3answers
77 views

I want to delete last letters of existing Contacts using Batch class. Is it possible? I want to delete all "sfdcpoint" letters

global class BatchApexExample implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { // collect the batches of records or objects ...
0
votes
2answers
30 views

Test unit for a scheduler

I have to develop a scheduler to process old registers of some object.. LastModifiedDate < LAST_N_DAYS:90 How can I create a test unit for such a scheduler? Is it possible to modify the ...
0
votes
2answers
408 views

Inserting Huge amount of Data in finish method in Batch Apex

I have a Batch class in which I am processing 10K records. The requirement is to create a file document in which all these 10K records which are processed should be listed. So, in my execute method I ...
0
votes
1answer
74 views

How To Process API Callout Response and SOQL Results in Batch

I have an existing scheduled callout which returns data that we save in Salesforce. The number of records being returned from the external webservice API is constantly increasing, so I would like to ...
0
votes
1answer
244 views

Fetch Batch Database.SaveResults from LWC

I'm working on a LWC component which will work as a simple snap-in to do basic data uploads for very non technical users. My issue is that I want to get the SaveResults from a batch, and pass it into ...
0
votes
1answer
38 views

unexpected token: BillingState

Im learning more about Batch Apex class and I find it pretty cool and helpful. When I remove the Where BillingSate='TX' everything works as expected. Yet when I use the Where condition I get the ...
0
votes
1answer
102 views

Is it possible to update the same field in same object for multiple updates in the same batch class

Please let me know is it best practice to update the same field with different status for the same object in same batch class global void execute(Database.BatchableContext BC, List<SObject> ...
0
votes
0answers
43 views

How to callout inside finish method of Apex batch? [duplicate]

I need to send some data to API when APEX execute success. When I put a callout method inside the finish method of the batch. There is always error shown: Too many future calls: 1 Example code: global ...
0
votes
0answers
34 views

Bulk Insert on Child Records

I am trying to implement one scenario for my educational purpose. I have 10 Account records and it has a field Country__c and I want to create 60K child Contact records for each Account Record. It is ...
1
vote
1answer
58 views

Working with large data volume

I have a design question and I want an expert opinion from the group. Here is the use case: Whenever there is any update on the Booking record (let's say change the status to "Cancelled"), ...
-2
votes
1answer
249 views

How can i convert apex method into batch?

public void addVisibilite() { Map<Id, List<Id>> accountContactRelationIdsMap = new Map<Id, List<Id>>(); for (AccountContactRelation accountContactRelation : (List<...
-1
votes
1answer
23 views

how to cover this catch in my batch?

for (APC_I_c rAPC : scope) { rAPC.Error__c = null; rAPC.Type_of_Error__c = null; rAPC.Status__c = 'Processed'; if(rAPC.APC_ID_Account_RCS__c != null){ ...
0
votes
1answer
155 views

Batch Data Entry no longer supported for Gift Entries in NPSP

I am trying to insert the gift entries to salesforce in NPSP but recently salesforce had blocked the use of Batch Data Entry and it showing the page as follows. Now sure how I am supposed to do the ...
-1
votes
1answer
290 views

How to use Map in query - Batch Apex

public toInsertOrderBillPriceShares_Batch() { for (AccountContactRelation accountContactRelation : (List<AccountContactRelation>) Trigger.new) { String oldRoles = (Trigger.isUpdate) ?...
-1
votes
1answer
201 views

Bulk Record Issue : Missing value for required field(s) in batch class [closed]

Problem facing : Missing value for required field(s): OrderFields: Debug Log details ordPrd.orderId*******null@@@@@@prdId@@@@@a0c3H000000SOp7QAG ord **********OrderItem:{ExternalId__c=24203223, ...
0
votes
0answers
33 views

Apex batch not committing records in production but executing without errors. Also working fine in sandbox

I have an apex batch which i tested in sandbox and it is working as expected but in production it is executing without error but not committing the records. I executed the same batch code in anonymous ...
2
votes
1answer
879 views

Bulk sending CustomNotifications using APEX

I could not find any post relating to this any help will be appreciated. Is there anyway to bulk send custom notifications from apex without using a process builder or API? If I use the following code,...
0
votes
1answer
37 views

Array of List<Contact>?

What syntax is needed to add multiple List of Sobjects to an array? I have this code currently in a batch class: public List<Contact> start(Database.BatchableContext bc) { List<Contact> ...
0
votes
1answer
137 views

SOQL Lookup != null condition in where clause is Selective or Non Selective?

I have a batch class to process some records Select Field1, Field2 from Object where Lookup_Field__c != null && Date_Field__c in (Date1, Date2) Now the Object that this query is on has more ...
0
votes
1answer
1k views

System.UnexpectedException: Start did not return a valid iterable object

I am trying to write a test method for my batch class so I can deploy it, but I am getting this error. System.UnexpectedException: Start did not return a valid iterable object. The batch class looks ...
0
votes
0answers
84 views

Batch Apex : Query data from one object and update data in another object based on data in 1st object

I've an object with a date field, if the date passes by a year from today(today - 365)... then i will have to fetch records from another object with name in: 1st object.name and update those records ...
0
votes
1answer
25 views

Task Trigger fired for one record after email send

I just learned in a very painful way that when sending SingleMessage emails tagged to be saved as activity the task trigger is called for each single message at once not in bulk. I'm sending from ...
0
votes
0answers
13 views

How to add conditions in a Batch class when there are n no of clauses

I want to add a clause in the query locator for billingCountry. The commented code runs fine but is there a way to do the same using the NOT IN clause ? I commented line 14,15 and trying to use line ...
0
votes
0answers
69 views

Calling a managed class (in vlocity) in a batch class APEX

Is it possible to make a batch class then call a managed class from the vlocity? I'm trying to do this but I don't have an idea how to start it since I couldn't see the parameters needed for that ...
6
votes
1answer
309 views

Custom Notifications not working on BatchApexErrorEvents

When long-running batches fail I want the starting user to be notified in the org using Custom Notifications. Therefore I added the marker-interface Database.RaisesPlatformEvents to the Batch class ...
0
votes
1answer
89 views

Convert Apex method to Batch [closed]

I want to convert this method to Batch Apex public void Visibility() { Map<Id, List<Id>> accountContactRelationIdsMap = new Map<Id, List<Id>>(); for (...
0
votes
0answers
28 views

can I compare two fields like this in system.assert? I have to test a method that assigns the field Name to External id [duplicate]

@isTest public with sharing class AccountTriggerTest { public static testMethod void metodoTestBeforeInsert() { Account account = new Account(Name = 'account_Test'); insert account; ...
0
votes
1answer
129 views

Test Class Coverage for Scheduled and Batch Classes

I am attempting to test a scheduled class that calls a batch class to update records. The following test class does not seem to find the Opportunity being created in the test class to pass that list ...
1
vote
1answer
46 views

Im getting "no viable alternative at character '&quot;'" while executing apex class for batch class

I have Created a Batch and test class for code coverage. However Im getting the following error message while executing the test apex. "no viable alternative at character '"'" Batch ...
0
votes
2answers
38 views

how can i leave a field without value if the condiction is true?

for(Account acc : lstAc){ Account acount = new Account(); if (acc.Property_Managment_Company__c == 'Independent') { acount.ParentId = THIS FIELD SHOULD BE EMPTY. }...
1
vote
1answer
146 views

I want to get number of user logged in to salesforce with specific profile

I want to get number of users logged into salesforce in every 30 minutes for specific profile. LoginHistory doesn't provide profilename/Id ,how can I achieve this
0
votes
0answers
16 views

my batch brings records and identifies if they're acc or cont for a particular field. How do I test it?

@isTest public class ALN_Integration_BatchTest { public static testMethod void metodoTest(){ ALN_Integration__c rec = new ALN_Integration__c(); rec.First_Name__c = '...
0
votes
2answers
142 views

Compare String value between runs in Batch Apex

I have the following block of code in Execute method of my batch apex class. for (String fieldKey : objectSchemaMap.get(scope.get(0).Object_Api_Name__c).getDescribe().fields.getMap().keySet()) { ...
0
votes
1answer
21 views

i'm testing a batch. In the last block i have to verify that the list is not empty and the name equal to 'Kinder'. How can I do that?

@isTest public class QWE_Integration_BatchTest { public static testMethod void metodoTest(){ QWE_Integration__c rec = new QWE_Integration__c(); rec.First_Name__c = '...
0
votes
0answers
22 views

Dynamically Scheduling Apex to Run at Various Points in Time for different set of records [duplicate]

My use case is that our Salesforce org will do callout to external system at different times of the day. All these data are stored in a custom object, which basically stores the external system URL ...
0
votes
1answer
26 views

what is wrong in this batch? [closed]

global class ALN_Integration_Batch implements Database.Batchable<sObject> { for (ALN_Integration__c recAln : lstCon) { AccountContactRelation acr = new ...
0
votes
1answer
30 views

Flag record that is successful upserted in a Batch execution

Have a Batch class that get values from a custom Object and create or update records in another Object. I'm having problem to mark the record from the first object as completed/processed when the ...
-2
votes
1answer
43 views

Is there any alternate ways to handle string in a better way in the below batch class. I feel it looks ugly? [closed]

global class batchFileUpdate implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext BC) { string reseller= 'RENEWAL_RESELLER'; ...
0
votes
1answer
335 views

Batch apex finish method emails firing multiple times [duplicate]

I have configured finish method to send error files on csv upload. It works ok for 200 records but if the sheet exceeds records more than 200 say 2000 I am getting emails for every job that has ...
1
vote
2answers
221 views

UNABLE TO LOCKROW when inserting contacts on a single account through batch apex

I'm trying to create bulk contacts on a single account. I followed the batch apex approach since I will be inserting over 1000 contacts on a single account at once. I triggered the batch apex from ...
0
votes
1answer
35 views

Issue accessing Custom Setting when instantiating Batch Class

I'm having issues returning values in a Custom setting (Type = List) when I'm instantiating a batch class, and I'm not sure why. I'm doing an upsert in my test class and confirming via system debug ...
0
votes
0answers
56 views

Batch Apex - SOAP Callout Issue

We have implemented a batch Apex solution for mass update records. More specifically, we upload a CSV file (more or less 2500 records) in a custom object and we "read" this CSV to create ...
0
votes
1answer
160 views

Batch job that sends notification to a Contact to complete a work order which was created a week ago

I am trying to create a batch job that sends a notification to a Contact to complete a work order which was due a week ago and if the custom field Resolution__c is empty. I've written the below code ...
0
votes
1answer
59 views

REST Callout query for high volume of records

I am working on the following scenario: Batch job which runs everyday, collects all Closed Cases for that day(usually, every minute 200 Cases are closed), invoke rest api for each Closed Case on that ...
0
votes
0answers
22 views

Contact Duplicate error not fired while upserting duplicate Contacts in bulk in apex

We have a Duplicate Rule defined on Contact Object. The requirement is to insert or update Contact records in Batch apex. Ideally, if any duplicate is found I should get Duplicate Error in apex. While ...
1
vote
1answer
68 views

SOQL Query on Collaboration Group fails only in live code, not in Execute Anonymous Window or Query Tab of Developer Console

Simple SOQL Query fails to yield results in live Apex code, but succeeds in Developer Console Execute Anonymous Window and in Query Editor Tab. public void importProgramCollaborationGroupTable(){ ...
2
votes
1answer
78 views

Batch Start Method Best Practice: DML/Scheduling?

During some solutioning design, my team has come across some complexity around batch scheduling. In order to maintain performance, we've been asked if it is okay to schedule the follow up batch in the ...
0
votes
1answer
40 views

Httprequest doesn't work in batch although Database.AllowsCallouts implemented

We are planning to start new integration functionality to a new system in our landscape (Workday). To do this we created integrations in apex with httpcallouts. We are planning to start the initial ...
-1
votes
1answer
54 views

"Variable does not exist" error in catch block even when the variable is outside the try block

I have written a batch class and using try-catch in its execute method. But on saving the class, getting variable does not exist error. Sample code is given below: global void execute(Database....

1 2 3
4
5
36