Questions tagged [stateful]

When using batch Apex, each batch keeps a separate state. So if we define a property in the class, it usually gets reset in each batch. In order to create a property that will maintain state across all batchs we need to implement the Database.Stateful keyword.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

Batch Apex - Static List not available in finish method

The issue I am facing is that I have a global static list declared in the batchClass. This list is populated after the values are obtained from a third party webservice. I am not able to ...
3
votes
2answers
63 views

Batch - Sending data from one batch to another

I having a little issue to understand the concept of passing params via batches. I have two batches which I would like to send data between them. Batch A creates a Map<sObject,Set<String>&...
0
votes
1answer
38 views

Sending data from one batch to another with amount of data

I have 2 Batches: Batch_A and Batch_B. I'm calling Batch_B in the finish method of Batch_A. I Implemented Database.Stateful to do so, and I'm wondering : How much Data can I send from one batch to ...
0
votes
1answer
38 views

Dynamic IF condition check

I have a requirement to check in an IF condition the various State names and then add each of the records in separate maps with respect to the state names. So each map will have the records of that ...
0
votes
1answer
358 views

Apex Batch Job ignores Records

I have created a stateful Apex Batch Job which is processing Permission Sets defined by a Set of Ids. I want to process each Permission Set individually so the batch size is 1. The batch job creates ...
2
votes
1answer
296 views

Schedulable equivalent of Database.Stateful?

I'm looking to implement a class that I can schedule every 5 minutes. This class will carry out some basic monitoring activity. But in order to know what to monitor, my scheduled class will need to ...
1
vote
1answer
381 views

Stateful Batch Apex with logic outside of the execute() method

I'm not even sure how to ask this question, but here goes: I have Batch class that needs to maintain state. The class looks something like this: global class myBatch implements Database.Batchable<...
1
vote
1answer
285 views

How do I maintain state for Dom.Document type variables between Start and execute method of a batch [closed]

I want to create a XML Head in start method of a batch class. I was getting "System.SerializationException: Not Serializable: dom.Document" error for DOM. To handle this I declared all the variables ...
7
votes
2answers
445 views

Why do static and non-static lists behave differently in batch and test contexts?

Given the following batch code: global without sharing class POCBatch implements Database.Stateful, Database.Batchable<Sobject>{ public static List<String> staticList = new List&...
3
votes
1answer
1k views

Passing a set of record Ids from a Stateful batch class to another batch class

I have an ever-evolving set of custom rollups from Tasks to Accounts, Contacts, and Leads. When I add a new rollup to the code, sometimes I need to calculate the value for all parent records. I've ...
-1
votes
1answer
611 views

Put a counter in batch apex class

I have a batch class in which i need to put a counter to count all the records that are processed successfully. My code is as follows: global class BatchUpdate implements Database.Batchable<...
5
votes
1answer
944 views

Database.Stateful and Database.SaveResult in a Batchable class giving internal errors

Usually when I write a class that implements Database.Batchable I end up saving errors in a variable(s) to sort through in the finish method and send out something about successes and failures. This ...
1
vote
1answer
3k views

Batch finish method getting null values

I'm implementing an apex batch process. public class BatchName implements Database.Batchable<XYZClass.wrapper>,Database.Stateful{ I have declared an integer variable as public and assigning ...
1
vote
1answer
627 views

Batch Job Callout You have uncommitted work pending. Please commit or rollback before calling out

I'm getting You have uncommitted work pending. Please commit or rollback before calling out global class BatchTransactionSurvey implements Database.Batchable<ManualSurveyController.SurveyData&...
0
votes
0answers
38 views

Finish block of apex is not running i think.Mail is not being sent

I am not getting any error but now Finish method is not executing i think as i am not getting system.debug logs for log statement added in the finish method.Any idea why i am not getting any finish ...
2
votes
1answer
47 views

Getting error in batch apex on runtime

I am getting runtime error with null pointer exception.In the debug logs it is showing value of idofacc is null. Please help its urgent. Batch Apex: global class testbatch implements Database....
1
vote
1answer
127 views

Efficient way to get the first data in batch process iteration

This problem is quite related to my first question in this link Get Data from batch iterable I have created a functionality that will upload data to salesforce object using csv. My problem at the ...
18
votes
1answer
1k views

Batch performance impact of Database.Stateful

I know that a Batch will generally run faster when the Database.Stateful marker interface is not used. What I don't know is, how badly the serializing and deserializing of state between each execute ...
3
votes
1answer
5k views

How do I pass an external variable into batch Apex?

I have a map variable that I am trying to pass into a batch class. This variable was created and populated in another batch class (which is why I can't just create it in the Start() method of the ...
5
votes
1answer
6k views

Accessing Non-Static Variables in Static Methods of a Visualforce Controller

I have a scenario where I have one Vf page called 'myVisualforce' and a custom controller 'myController'. In myController I have some non-static variables for example 'var1' and 'var2' and I have few ...
7
votes
1answer
1k views

keeping a running count (rollup) with batch apex

Is it possible to keep a running count of all tasks by whoId in batch apex? I want to aggregate all tasks for a contact, but how do you prevent the count from resetting after each batch? global ...