Salesforce Fact #627 | Passing list of Sobject across batch apex
Suppose we need to pass List<Sobject> records from one batch apex to another. We can call the 2nd batch from finish method of the 1st one and pass the list of records.
In this example, we are creating 5 account records in batch1 and then passing the records to batch2 from the finish method of 1st batch. In this case, we need to use the Iterable<SObject> type and the 1st batch needs to implement Database.Stateful interface to retain the value.
Attached are the screenshots.
Comments
Post a Comment