30 lines
1.1 KiB
OpenEdge ABL
30 lines
1.1 KiB
OpenEdge ABL
global class CallingFromTrigger implements DataBase.Batchable<sObject>{
|
|
List<Contact>contlist=new List<Contact>();
|
|
global CallingFromTrigger(List<Contact>clist){
|
|
contlist=clist;
|
|
}
|
|
global DataBase.QueryLocator start(Database.BatchableContext BC){
|
|
return(DataBase.getQueryLocator([SELECT Id,Email FROM Contact WHERE Id IN:contlist]));
|
|
|
|
}
|
|
global void execute(Database.BatchableContext BC,List<Contact>Scope){
|
|
for(Contact c:Scope){
|
|
c.Description='if Email available then we have sent email';
|
|
|
|
}
|
|
Database.update(Scope);
|
|
}
|
|
global void finish(Database.BatchableContext BC){
|
|
for(Contact c:contlist){
|
|
if(c.Email!=null){
|
|
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
|
|
mail.setToAddresses(new String[] {c.Email});
|
|
mail.setSubject('Added in Contact');
|
|
String messageBody = 'Hii you are added in contact';
|
|
mail.setPlainTextBody(messageBody);
|
|
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
|
|
}
|
|
}
|
|
}
|
|
|
|
} |