SHARE
TWEET

Untitled

a guest Nov 14th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global with sharing class RequalificationEmailBatch implements Database.Batchable<sObject>{
  2.     String query;
  3.    
  4.     global RequalificationEmailBatch() {
  5.         Date dateField = System.today() + 1 ;
  6.         String dateFieldString = String.valueOf(dateField).substring(0, 10);
  7.         query = 'SELECT id, name, PersonContactIdAuto__c, Requal_Email_Response_received__c, email__c, RecordTypeName__c, ' +
  8.                 'Requal_Email_Sent_On__c, Skip_Validation_New__c, bookingDate__c, MovingoutDate__c ' +
  9.                 'FROM Opportunity WHERE (stageName = \'Closed Won\' OR stageName = \'Payment Pending\') ' +
  10.                 ' and MovingOutDate__c > ' + dateFieldString;//
  11.  
  12.         // additional condition when code executing in sandbox to avoid emails sent to real customers/emails
  13.         //if(RequalificationEmailHelper.runningInASandbox())
  14.         //    query += ' AND email__c = \'sf-test@movinga.de\'';
  15.  
  16.         system.debug('>>>>>>>>>>>>>  ' + query);
  17.                
  18.     }
  19.      
  20.     global Database.QueryLocator start(Database.BatchableContext BC) {
  21.         return Database.getQueryLocator(query);
  22.     }
  23.  
  24.     global void execute(Database.BatchableContext BC, List<sObject> scope) {
  25.         RequalificationEmailHelper.sendEmailsAndGenerateCases(scope);
  26.     }
  27.    
  28.     global void finish(Database.BatchableContext BC) {
  29.    
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top