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
28 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
26 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
28 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 ...
-2
votes
0answers
16 views

Batch Apex: Query Two objects. I've query on object1 and based on records in obj1, i've to query obj2 and update obj2 [closed]

Batch Apex: Query Two objects. I've to query on object1 and based on records in obj1, i've to query obj2 and update obj2. please advise how to query two objects. Thanks...
0
votes
0answers
15 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
21 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
9 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
8 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 ...
5
votes
1answer
87 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
37 views

Convert Apex method to Batch [closed]

I want to convert this method to Batch Apex public void addVisibilite() { Map<Id, List<Id>> accountContactRelationIdsMap = new Map<Id, List<Id>>(); for (...
0
votes
0answers
16 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
32 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
18 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
36 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
42 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
48 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
18 views

Internal Server Error on Old Sandbox Records - Best Approach

We have a sandbox that is partial. It would appear that the refresh did not bring down everything it was supposed to in order for the instance to work properly. I'm currently working on a batchClass ...
0
votes
0answers
21 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
24 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
21 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
36 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
0answers
28 views

how to create a related list of object in test class

I have created a test class. Related list part is not covering. On product object UP Relationship is a related list. I have craeted a product and created UP Relationship nd inserted. how to cover if ...
0
votes
1answer
49 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
51 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
31 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
41 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
22 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
38 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
19 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
33 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
33 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
32 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
39 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....
0
votes
2answers
47 views

Apex Batch Job Start Method

I need to set up a daily batch job that makes an REST API call to an external service and updates contact records in salesforce. The data in the external service changes once daily. The external ...
0
votes
3answers
114 views

Constructor not defined: .<Constructor>()

can anyone please help with how to resolve this error? I am getting this error Constructor not defined: [GA_AP_CreatePartnerUsers].<Constructor>() at GA_AP_CreatePartnerUsers CreatePartnerUsers ...
0
votes
0answers
33 views

The execute method in my apex batch job is not being covered [duplicate]

Batch job class: public class Renewal_job implements Database.Batchable<SObject> { //public Renewal_job() { //} public Database.QueryLocator start(Database.BatchableContext bc){ ...
0
votes
2answers
37 views

Design to run a batchable after a trigger and account for multiple workflows

Our current design starts from a trigger, checks the data against a bunch of rules that the customer sets up. The ones that pass get sent to another job which exports it to another external system ...
0
votes
0answers
44 views

Batch Apex Too many SOQL Queries: 201 on a relationship query

REQUIREMENT Create a batch apex class that needs to update all of the accounts based on the number of contracts and opportunities for that certain account. Here is what I have so far. However, I am ...
0
votes
1answer
53 views

Test Class for batch apex - Getting Error

I'm looking to see if anyone could provide any pointers on the test class I'm trying to write for the following batch class: public with sharing class TerritoryReassignmentAccounts implements Database....
0
votes
1answer
66 views

Using BatchApexErrorEvent vs custom platform event on error

Working with a consultant on a batch class that performs operations on the user object. We are working on implementing error handling. We must use platform events to handle errors to avoid mixed DML ...
0
votes
1answer
32 views

Map giving same data of object while using loop [closed]

I am using a batch class where data iterated over an object Now i am trying to retrieve some fields iterating over object1 Issue - its giving me common id for provider Base value
2
votes
1answer
52 views

Prevent limits in a callout intensive process where client can only receive one request at a time?

I have a callout intensive process where the client can only receive one request at a time and I'm having a hard time identifying what is the best practice for asynchronous solutions to handle this ...
1
vote
1answer
28 views

Add Contacts to Campaign as Campaign Members using batch class

I have a requirement where I need to add Contacts to a specific campaign record as campaign members when the status(Custom Field) of Contact is Closed Lost. I was stuck as adding contacts to campaign ...
0
votes
2answers
51 views

Email Limit Exceeded on Batch Apex

I have a batch job which sends email notification in bulk using Messaging.sendEmail() and its using setTargetObjectId to set the reciepient. It sends out thousands of emails but one day I got case ...
0
votes
0answers
27 views

how to soql query from ContentDocumentLink for batch? [duplicate]

i'm struggling with understanding the logic behind this query i need to do for a batch job. i am querying the contentdocumentlink object because i need to capture files (potentially multiple) related ...
1
vote
0answers
37 views

Apex Job Gets Stuck Processing

I have the following problem. There is an Apex Scheduled job that runs everyday at 2AM that gets stuck during processing. As seen in the image below, the batch process reaches 330 and then stalls ...
0
votes
2answers
46 views

Cannot make callout from a Trigger that is fired through a batch apex

I'm trying to call a method which do an api call. But I'm getting an error because this method get call through the process ran by batch. So even if I directly call the API calling method it gives me ...
0
votes
1answer
27 views

how to write test class for batch class ? this covers only 44% [duplicate]

how to write test class for batch class ? this covers only 44% global Class Batchsample implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database....

1
2 3 4 5
33