You need to sign in to do that
Don't have an account?
Creating a wrapper class in batch apex
Hi everyone,
I have created a wrapper class in batch apex and created a list of that class. I did some calculation in execute method and store some data but i am not able to get that data in finish method. My wrapper class is public and List<wrapper class> is private.
Can anybody help me?
So from what I'm understanding you're building a list of your custom wrapper class in your execute method, and maintaining that list at the class instance level. You then want to use said list in the finish method.
If so try using the Database.stateful interface in your Batch APEX class:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
See: Database.Stateful
Be careful though, since maintaining these objects adds to your total heap size usage
All Answers
So from what I'm understanding you're building a list of your custom wrapper class in your execute method, and maintaining that list at the class instance level. You then want to use said list in the finish method.
If so try using the Database.stateful interface in your Batch APEX class:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
See: Database.Stateful
Be careful though, since maintaining these objects adds to your total heap size usage
Hi Sean Tan,
Thanks a lot for your solution. It worked for me.