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)

2
votes
1answer
22 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
24 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
0answers
22 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
0answers
8 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
27 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
12 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
26 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
96 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
28 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
16 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
35 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
50 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
31 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
37 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
344 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
38 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
28 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
36 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
20 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
85 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
70 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
29 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
20 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
18 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
37 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
79 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' ...
-1
votes
1answer
78 views

Using Batch APEX to generate template body dynamically with merge field values

I am using Amazon SES to send mails to the all opportunities using batch apex with the body of email template. I'm using the solution proposed in an answer to Using APEX to assemble HTML Letterhead ...
0
votes
0answers
32 views

Design Approach: Apex Callout limits

I am developing an appexchange managed application intended for multiple subscribing organizations and as a part of requirement my managed application needs to make an extensive API callout to an ...
1
vote
1answer
119 views

Using Batch apex Insert new records in to custom object from json string in salesforce

I am trying to insert json data in to salesforce objects. Json string is too large so i am using batch apex to insert data. For this I had written apex class i didn't got any error But records not ...
2
votes
0answers
70 views

Accessing Custom Labels through Batch Apex

We have a mobile application which needs custom labels for different languages through Salesforce custom labels. Because of API limit on metadata api, we are planning to store all the required custom ...
1
vote
1answer
53 views

Can we create .csv file with a Batch Apex

Can we create a batch class where we can query the records and generate a .csv file . I have to automate the process and team is not interest in having a server where i can host the Command line ...
3
votes
1answer
53 views

Batch Apex gets stuck in Queued status for a long time

We have an apex job that gets stuck in "Queued" status for a long time before going into "Processing". This happens only in Sandbox environment (which was recently refreshed from Prod btw) and not in ...
1
vote
1answer
30 views

How do I create/update bulk records in one execution synchronously?

I have object A which has 2 Lakh records. A child has to be created under each of these records on a click of a button and show them on a vf page. I am hitting a lot of limitations like 1) 50001 ...
1
vote
1answer
64 views

code coverage for the test class

i have a batch class which i am scheduling for run. and i have a test class for the batch class. the batch class is working fine . but the code coverage is 44% . important note: when the batch ...
0
votes
1answer
52 views

Found null SObject at position 0 in data taken from Batchable Map

I am running the below code but getting a DML error for my database.delete statement found null SObject at position 0 error. global class RevenueSchedulerBatch implements Database.Batchable ...
1
vote
0answers
49 views

How to get the value from a batch apex class to a normal apex class

So I've created a batch class, did a query, and stored the results into a map. Now I know that you can pass values from one batch to another with cascading batch calls and database.stateful, but is ...
0
votes
1answer
115 views

batch class execute() method not covered by test class

Need to raise the covered line on this apex code could you kindly point out the missing piece of code for my test class. It does not covered the code in bold face (global void ...
1
vote
1answer
45 views

Can you run a Batchable Apex bulk update as a different user?

I have been running my Batchable Apex bulk update from the developer console so it runs with my permissions. Is it possible to run it as another user? Ideally I'd like to run it under the API profile ...
0
votes
1answer
44 views

How to manually give a callout in test class

I needed to throw a callout exception by hardcoding it in test class for batch class.Is there any method to do that ? try{ XXXX } catch (CalloutException excpObj) { ...
1
vote
0answers
28 views

How to populate a map using Batch

So I have to create a map using an object implementing the batch interface. I have used the Database.stateful interface to make sure all instances of the batch are inserting into the same table. The ...
0
votes
1answer
25 views

How can I know if it's the last execution of all the batches?

I have a shared Map type instance variable that I want to process after all batches are executed. public Map<String,List<ID>> territoryClientIDMap=new Map<String,List<ID>>(); ...
-1
votes
1answer
47 views

How to use report result as input to Batch Apex

Let's say I have a report with a specific result. Now i want to process this result in a batch process when the user triggers a order-button/link. Is there a way to have a button on the report page ...
0
votes
0answers
49 views

Updates by apex class are partially successful,unable to debug

I have a batch apex class in production that deals with custom objects Call2_vod__c and Hcp_Depth_Tracker. Finds out number of calls with same Account field and Territory field value and updates the ...
1
vote
0answers
102 views

error from test method - “apex job is already scheduled for execution”

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
0
votes
3answers
57 views

Batch apex failling silently for some records

I am writing a batchable apex class and am finding that every time I run it, some rows are not being processed. The strange thing is when I look at the apex job monitoring page, the number of ...
3
votes
0answers
75 views

Best way to bulk update data in salesforce

We have created a trigger that generates some information for a column on the Opportunity object. We now want all 400,000 existing opportunities to have the same information. The logic is encapsulated ...
2
votes
1answer
67 views

Are static variables reset per batch during bulk DML operation? (Executing triggers for field updates)

A while back I had a trigger issue where I needed a trigger operation to execute exclusively on the second update or an update after an insert. So I had some code like this: Trigger Handler Class ...
1
vote
1answer
27 views

How does the batch execution fetch records to do any operations

Okay, I have huge set of records in a Custom object and i'm fetching these to do some kind of DML operations. During this batch process, how exactly does the records are fetched as in what order and ...
0
votes
2answers
39 views

Batch Class CallOutLimit Doubt

As we have 10 callout governor Limit in each execution . So I can query 100 records in start and execute the batch class with batch size as 1 and do 10 callout for each record . So total I can query ...