Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How can I schedule batch apex code?

Asked by Dipesh Bhardwaj Apr 20, 2023 1.3K views 1 answer
Share

About this question

This is my batch apex code

global class batchAUpdate_based_on_stage implements Database.Batchable { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'SELECT Id,Name,child_stage__c FROM Child__c '; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List scope) { for (child__c child : scope){ if(child.child_stage__c == '25%'){ child.child_stage__c = '100%'; } update child; } } global void finish(Database.BatchableContext BC) { } }

And this is my scheduler class when i save it i'm not getting in the scheduled job list, i mean at Setup>monitor>scheduled job

global class Scheduler_class implements Schedulable{ global void execute (SchedulableContext SC){ batchAUpdate_based_on_stage b1 = new batchAUpdate_based_on_stage(); database.executeBatch(b1); // string sch = '0 0 0 1 4 ?'; string sch = '0 1 1 * * ?'; system.schedule ('Batch', sch, new Scheduler_class()); } }

Where am I going wrong?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.