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.

learn more… | top users | synonyms (1)

0
votes
0answers
13 views

Import Large CSV file using Batch Apex [duplicate]

I have a requirement to read a large csv file and insert into database. My code works fine for 3000 records but after that it gives me CPU time exception or Regex is too complicated. So, I thought to ...
0
votes
1answer
15 views

Error in debug log though class compiled correctly

I have below batch class which compiles correctly but throws error runtime says expecting colon Error: FATAL_ERROR|System.QueryException: expecting a colon, found '(' ...
0
votes
0answers
19 views

First error: invalid character encoding - Apex Job

I have written an apex batch that was working before sendbox refreshing. When I try to run the batch I get this message in the Status Detail: First error: invalid character encoding Instead in the ...
1
vote
0answers
33 views

Scheduled apex to run only twice a day

I have the following Scheduled apex class. The aim is to run batch processes twice a day so i.e : Create case at 12pm, link the cases to accounts at 12:10pm then again at 12am and 12:10am. However, ...
0
votes
2answers
36 views

Please help! First error: Too many query rows: 50001 in my Batch Job

please help on my Batch Apex Job, it kept on prompt me error 'First error: Too many query rows: 50001' and i cant reduce the result return from my statement, i need to process all data, can anyone ...
3
votes
1answer
37 views

is it possible to call a single batch job from multiple schedule apex?

Hi i would like to know is it possible to have multiple scheduled Apex calling a single Batch Apex? The reason why i have multiple schedule apex is becaus different each 1 excute a different record ...
3
votes
1answer
42 views

Do we allow CRUD & FLS in each component of Apex?

Can I write CRUD & FLS Enforecement codes in following : If not in any of these - then Why ? Apex Class - YES Apex Trigger - ? Apex BatchClasses - ? Utility Classes - ?
0
votes
1answer
15 views

Why Batch can't work in unit-test? [duplicate]

There are 2 methods will callout and insert.I wrote 2 batches to invoke my method. I use the one invoke the other one to avoid System.CalloutException,and it's useful when i run them. global void ...
1
vote
1answer
19 views

Question on an interesting map syntax

I recently came across a rather interesting syntax of a map in a batch apex which I would be grateful if anyone can explain to me how it's actually working: global class CommissionSharingRecalc ...
1
vote
1answer
18 views

Test cases for the Batch APEX sending Emails

Need help in increasing the code coverage for the batch class. I have 5 such similar Batch classes where I have t increase CODE COVERAGE. They are all working fine in production, but due to code ...
1
vote
1answer
20 views

Detecting and retrying CalloutException in Batchable iterable

I have a nightly batchable job in my SFDC org that queries a remote SFDC org for account and opportunities meeting certain criteria. Works great but every so often, I get System.calloutException read ...
2
votes
0answers
40 views

Apex code to Export Csv file to ftp server

I have to write an apex batch scheduler to send user information csv to some ftp server. I am able to generate the csv file with user records but I don't know how to send this csv file to ftp server ...
1
vote
1answer
32 views

Type casting error

I am getting runtime type casting error with below code. Can someone please help? Code: global class batchCallUpdate implements Database.Batchable<sObject> { global Database.QueryLocator ...
1
vote
0answers
15 views

Flexible API Limits—Question

Please can someone confirm the following about Flexible API limits: Provides the ability for me to queue up more than (5) batch jobs for processing. Only (5) jobs are executing at any one time and ...
0
votes
1answer
36 views

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

I have a batch class that makes a external Http callout to create case records with a CreatePublicStuffCases() which is called in the start(). In the execute function, I have another callout to get ...
0
votes
0answers
12 views

Within Batch Apex, how to execute query using a list view filterId

I am trying to pull selected view records in Batch Apex Can Any body give me help me how can i make query in Database.getQueryLocator(); to pull all records of the view Query = 'select id,name from ...
1
vote
1answer
33 views

How to test callout in batch

I'm trying test a critical part of an application that is in a batch process and makes callouts to a server. MyObject__c obj = new MyObject__c(name='test'); insert obj; Test.startTest(); ...
5
votes
2answers
88 views

Best practises for speeding up Apex Batch class

My previous question about slow Batches probably was to focused on a specific problem, so I try it again much broader. What are general rules of thumb to make a slow Batch faster? Although I added 2 ...
5
votes
2answers
105 views

Only query Id field in start() to speed up Apex Batch

I am looking for ways to speed up a complex Batch job which takes days to run in a specific customer org. This Batch is snapshoting records of arbitrary objects into denormalized (as a single records ...
0
votes
2answers
35 views

Test Coverage for Batch Class

I have the following Batch class which operates on a custom object (Sample__c) and the default Contact object. My test class goal was to create a list of Samples which I know satisfy the batch's query ...
3
votes
1answer
66 views

scheduled apex to query and create new sObject

I am currently working on creating a scheduled apex to query an external json case objects and insert these objects in salesforce. I am quite new to this framework and quite stuck. The below is a how ...
2
votes
1answer
62 views

Can Queueable solve “Future method cannot be called from a future or batch method”?

I have code that must be called as @future as it requires all the resources one can get. The only problem is that in 1% of the cases this code is called from a Batch and therefore fails with ...
6
votes
4answers
121 views

What is the best approach to mass create records from a button click?

My requirements are that I have to create a class that creates 400 to 600 records on a custom object once a button is clicked. I figure the best approach is to create a static webservice method that ...
3
votes
1answer
40 views

Test Class not covering the execute method

This batch class is to set the recordtype when it is null. global class ContactBatch implements Database.Batchable<SObject> { global String query; global Database.QueryLocator ...
2
votes
2answers
100 views

Calling future method from batch class?

I got a situation where i need to invoke future method from batch class. And i know that it is not possible to do. But there might be some workarounds to achieve it, right? And i dont want to invoke ...
0
votes
1answer
70 views

Apex Batch job to get Users information

I am new to the salesforce. I am working on the Apex batch jobto get Users info which is class User and stored into the csv/text file. I want username and user emailid stored of All users and this ...
1
vote
1answer
18 views

Issue with imported data missing household address in NPSP 3.0

I imported a bunch of contacts with household accounts (not using the npsp importer just the regular data migration tool). Everything seemed to go in correctly but for some reason the address didnt ...
0
votes
2answers
31 views

Batch class to set the recordtype

This batch class is created to set a recordtype to the records having NULL recordtypes. But it throws an error FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object in line ...
3
votes
0answers
17 views

Does 'Deploy with Active Jobs' work for managed packages?

So there's this new feature: 'Deploy with Active Jobs' It lets you deploy batches and schedules even if they're running. This is great for changesets. Does it work with managed packages?
2
votes
1answer
30 views

Has anyone created a report snapshot capability via batch apex and knows how to write a test class for this scenario?

I've come across some great threads on using Apex batch and schedule classes to overcome the 2K governor limits on reporting snapshots. For an example of the model I followed, see this article: How ...
2
votes
1answer
112 views

Checking fields for Blank or Null

I am building a CSV file from an sobject list in a batch class. There are certain fields that are appearing as "NULL". When I am checking them for NULL values using IsBlank , I am getting an error ...
0
votes
0answers
31 views

Multiple File Data Set Import Cleaning

It is pre-Salesforce import, I have designed the Named Account structure inside Salesforce, and I have 1500 Hoover's D&B Family Trees with the same columns and headers in .xls form. What do I use ...
0
votes
2answers
19 views

Batch class approach restrict multiple email

I have a requirement to send mails some Users (DM lookup ids) notified about creation of records in a custom object based on a specific filter criteria. Now if there are records in different batches ...
5
votes
1answer
56 views

Can I tell how many records in a Database.QueryLocator()?

According to the documentation, in a batch a Database.QueryLocator can retrieve up to 50 million records. A maximum of 50 million records can be returned in the Database.QueryLocator object. If ...
4
votes
1answer
60 views

Create Bulk Record using apex

How I can Create 5000 new Lead record and each Leadname will be different like List<Lead> lList = new List<Lead>(); for(Integer i = 0; i<5000; i++){ Lead l = new Lead(LastName = ...
0
votes
1answer
34 views

Want to revert back previous field value

how to get the previous 'LastName' field values for Standard object Lead? global class UpdateLeadBatch implements Database.Batchable<SObject>{ global final String Query; global final ...
0
votes
1answer
47 views

how to get all records in batch job?

How to get all record in batch? my requirement need to get all records from a object. but, SFDC batch size limit is 2000, even if i use iterable batch still can not get all records. If i use ...
19
votes
9answers
365 views

How can I cause side effects outside a transaction context?

I've got a scenario that relies on the system's "automatic rollback" behaviour to undo any DML, emails, futures and so on, in the case of an error. Basically, by allowing code to throw an unhandled ...
1
vote
2answers
41 views

Can any one correct this one why batch apex is not deleting records?

Here is my batch apex .it is not deleting records global class BatchProcessorder implements Database.Batchable<sObject>{ String query; DateTime lastTwoDays = ...
0
votes
0answers
14 views

Batch apex error “Apex CPU Time limit exceeded error” [duplicate]

I have created batch apex class to insert records into salesforce but i got an error i.e."CPU time limit exceeded error" Please help me to solve this error. global virtual class InsertProductData ...
1
vote
0answers
33 views

Batch Iterable (Apex CPU time limit exceeded) List<Map<>>

I'm not sure what I'm doing wrong with my Batch Iterable class. I'm trying to create a List of Maps. I'm passing in an entire Map (accountToNewAndOld) which gets broken up into and added into a List ...
0
votes
0answers
42 views

Any work around to run 100+ jobs run or way

While saving 100+ jobs at a specified time i am getting error "You have exceeded the maximum number (100) of Apex scheduled jobs" If i want to use one scheduler to run all , we gonna have two issues. ...
1
vote
1answer
25 views

Database.DeleteResult.getErrors() question

I am trying to connect specific records that fail to delete in my batch job to their error messages. I thought my solution was working, but I checked the size of .getErrors() and it's size 1. My test ...
3
votes
1answer
147 views

System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execute, or future method on batch within batch

I am attempting to call a batch within a batch. The reason why I am attempting this is because the values returned in the main batch is used in a query to grab other records to be updated from a ...
1
vote
1answer
85 views

Batch apex error in apex job : Exceeded max size limit of 3000000

Using Batch apex i am trying to Insert new records in to custom object from json string in salesforce from API url. When my batch apex class run i got this error in apex log. please explain me
2
votes
1answer
34 views

Performance impact of relationship queries in batch start

For a new batch process I have a choice between immediately selecting relevant records in the start function (but using several [field]__r comparisons as they are junction objects being queried) or ...
3
votes
1answer
27 views

Why should a queryString variable in an apex batch class declared as global?

Every documentation on batch apex class shows the queryString variable declared as global. Is there a specific reason for doing so??
0
votes
0answers
25 views

Batch Processing: “Read Timed Out” Error

I am trying to add records from API URL using batch apex in salesforce. I got an error while running batch apex. Please help me to solve this error.
0
votes
1answer
41 views

@future solves ERROR: MIXED_DML_OPERATION but Batch fails

A user is automatically created in the backend whenever a contact is created in the sf console. A custom field, DivisionCs is filled during that automated process. We want the same field to be updated ...
3
votes
2answers
98 views

SOSL query in Batch apex

Can a SOSL query be used in the Batch apex start method? I used the below code global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator([FIND '.com' ...