You need to sign in to do that
Don't have an account?
gowtham murugesan
hi all,Please give me test class for this
My below batch class is working fine,kindly give me test class for this,its totally new for me.
global class AccountUndeleteBatchApex implements Database.Batchable<sObject>{
global Database.queryLocator start(Database.BatchableContext bc){
String query = 'SELECT Id,Name FROM Account WHERE IsDeleted = True ALL ROWS ';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
List<Account> accList = new List<Account>();
list<Deleted_Record_ID__c> DelRe = new list<Deleted_Record_ID__c>();
for(Account s:scope){
accList.add(s);
}
System.debug('account list' + accList );
for(Account ac:accList){
Deleted_Record_ID__c dr=new Deleted_Record_ID__c();
dr.Name = ac.id;
dr.Name__c = ac.Name;
DelRe.add(dr);
}
insert DelRe;
Undelete accList;
}
global void finish(Database.BatchableContext bc){
}
}
global class AccountUndeleteBatchApex implements Database.Batchable<sObject>{
global Database.queryLocator start(Database.BatchableContext bc){
String query = 'SELECT Id,Name FROM Account WHERE IsDeleted = True ALL ROWS ';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Account> scope){
List<Account> accList = new List<Account>();
list<Deleted_Record_ID__c> DelRe = new list<Deleted_Record_ID__c>();
for(Account s:scope){
accList.add(s);
}
System.debug('account list' + accList );
for(Account ac:accList){
Deleted_Record_ID__c dr=new Deleted_Record_ID__c();
dr.Name = ac.id;
dr.Name__c = ac.Name;
DelRe.add(dr);
}
insert DelRe;
Undelete accList;
}
global void finish(Database.BatchableContext bc){
}
}
Greetings to you!
Please try the below code, I have tested in my org and it is working fine.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas