You need to sign in to do that
Don't have an account?
fiona gentry
How To Execute Below code In Anonymous Block
Dear Gurus,
I have a need where in i require to execute below code in Anonymous block,
what changes i need to make in below scheduled apex to make it execute in anonymous block,i just need to execute the code
Thanks in advance,
Fiona
I have a need where in i require to execute below code in Anonymous block,
what changes i need to make in below scheduled apex to make it execute in anonymous block,i just need to execute the code
global class ERT_CaseCopyBatch implements Database.Batchable<sObject>, Database.Stateful { private List<ERT_Case_Type__c> processedRecords; global Database.QueryLocator start(Database.BatchableContext BC) { processedRecords = new List<ERT_Case_Type__c>(); // collect the batches of records or objects to be passed to execute String query = 'SELECT Case__c, Level_1__c, Level_2__c,Level_3__c,UniqueGUID__c FROM ERT_Case_Type__c WHERE createddate = today AND IsProcessed__c = false'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) { // process each batch of records List<Case_Type__c> listCTD = new List<Case_Type__c>(); for(ERT_Case_Type__c exe : exeList) { listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c,ERTUniqueGUID__c=exe.UniqueGUID__c)); exe.IsProcessed__c = true; } try { insert listCTD; //only successful batches will be processed processedRecords.addAll(exeList); update processedRecords; } catch(Exception e) { System.debug(e); } } global void finish(Database.BatchableContext BC) { } }
Thanks in advance,
Fiona
>To run the batch class, you need to execute below: The batchJobId will contain the job Id of the batch. To monitor or stop the execution of the batch Apex job: from Setup, enter Apex Jobs in the Quick Find box, then select Apex Jobs. 200 is the batch size.
>If you want to schedule this batch class you need to use scheduler class as below
Then you just need to run Scheduler_class.scheduleMe(); from execute anonymous and it will be scheduled to run at your interval.
Related:https://salesforce.stackexchange.com/questions/24467/scheduling-batch-apex
If this information helps, please mark the answer as best. Thank you
All Answers
>To run the batch class, you need to execute below: The batchJobId will contain the job Id of the batch. To monitor or stop the execution of the batch Apex job: from Setup, enter Apex Jobs in the Quick Find box, then select Apex Jobs. 200 is the batch size.
>If you want to schedule this batch class you need to use scheduler class as below
Then you just need to run Scheduler_class.scheduleMe(); from execute anonymous and it will be scheduled to run at your interval.
Related:https://salesforce.stackexchange.com/questions/24467/scheduling-batch-apex
If this information helps, please mark the answer as best. Thank you
Kindly find solution.
You can execute this Batch Class from Anonymous Window in your Org by just putting this code. If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.