+ Start a Discussion
S Babu.ax1883S Babu.ax1883 

batch apex class to find the current class

I have Active__C field and Expiration_Date__c field. If the active__c Flag is true, then the Expiration_Date__c must be greaterthan current date. 
I need to write Batch apex class for this requirement.This Batch apex class runs on thousands of records.
Please help me any one know how to write code for this.

So you are saying if active__c flag is true you have to set the Expiration_date__c to greater than today?
global class UpdateDate implements Database.Batchable<sObject>, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT active__c,Expiration_date__c FROM yourobject WHERE active__c= TRUE ';
return Database.getQueryLocator(query);

global void execute(Database.BatchableContext BC, List<yourobject> scope) {
for(yourobject x : scope)
x.Expiration_date__c = "Your Custom Date";
}Update scope;
global void finish(Database.BatchableContext BC) {