function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raj_sfdccraj_sfdcc 

Convert Apex class to Batch apex class.

Hello All ,
We have VisualForce page which includes button called 'Generate'  so when we click on that button apex class( 'createRecord' ) will be called and which will create two types of objects records .

Issue :Now the problem is the apex class is creating more number of records which is hitting governor limt(Error :CPU Limit Exceeded) .

So we are planning to conver apex class to Batch apex class to avoid hitting governor limits .

Help Needed :
Since apex class is undergoing with many Lists ,Maps and validations in apex class before preparing final records list to insert ..

So is it possible to call batch class from current apex class by passing two final list of records to insert to the batch class and do the insertion in excute method ?

If above is not possible then can we include all complex list ,maps and validation to get final insert list of records in batch class .if yes please give me an idea .
Raj VakatiRaj Vakati
Can you share the code so that i will be able to answer yes or not ..But based above we can able to say yes