You need to sign in to do that
Don't have an account?
Ankit Singhal
How to pass a List of Task Records to Batch class
i want to pass a list of task records
say
List<Task> Tasklist
to the batch class for insertion.
How to call Batch class for this list of tasks.
Why do you want to insert in batches? What will trigger this apex? Can you add some more detail of your requirement?
Often, the community is able to provide better solutions to your requirements than trying to fix a problem while doing it your way so its always better to tell us what problem you're trying to solve...
~LVS
Hi,
I want to do it in batch because task records in list are more than 50k.
So this is a client reuirement.
i have a Utility class SMPDAO
say
public Class SMPDAO
{
public static TaskReturn(Arg1,Arg2)
{
if (Tasklist.size()>50000)
//then need to use batch to insert Task records
else
insert Tasklist;
}
}
Now since i have never used batch Class,can u plz guide me how to pass this list as Arguement to Batch Class.
tHanks in Advance.
Can Try Below:
List<task> Lst_Task = [Select Id from Task Limit 50000];
I would suggest to use WHERE clause to filter out desired records in SOQL .So that it wil not give query time out error . If there are large amount of data .
Note that any set of records queried from the start() method of a batch class is automatically broken into batches and the execute() method is called for each batch
Please refer the Apex Batch documentation here for more detail.
Since you are working with a large data set, I recommend you read this as well: http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm
Hi Ankit,
In a Batch class, we pass the set of records that are to be processed, in your case there are no records (they have not yet been inserted). So I don't think this is the correct solution for your requirement.
How is the TaskList getting filled in your code?
Hi Ankit,
I hope you can done this insert process without use of a Batch Process, by iterating your records over a for loop.
and if you want to use a Batch Apex process for your task. Refer the following link:
http://salesforcesource.blogspot.in/2010/02/utilizing-power-of-batch-apex-and-async.html
http://blogs.developerforce.com/systems-integrator/2009/05/batch-apex-a-powerful-new-functionality-in-summer-09.html
These links are have good information about Batch Process and it also have example code for Batch Process .
I hope this will helpful to you.