• Kumar Saurav 16
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
global class ABI_SFA_TAC_Removal_Batch implements Database.batchable<sObject>
{    
    // variable decleration.
    public String Query;
               
     /* 
     Method Name: Start
     Description: This method is used to collect the TAC records ready for deletion.     
    */
    global Database.QueryLocator Start(Database.BatchableContext info)
    { 
       // fetch TAC records ready for removal.
        
		String Query = 'SELECT ABI_SFA_Account_Removal__c,ABI_SFA_Account__c,ABI_SFA_RecordID__c,ABI_SFA_SHAREID__c, ABI_SFA_Type__c,ABI_SFA_User__c,ABI_SFA_Valid_Till__c,CreatedById,CreatedDate,CurrencyIsoCode,Id,IsDeleted,LastModifiedById,LastModifiedDate,Name,OwnerId,SystemModstamp FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like '%Europromotion%' LIMIT 50000';
       
       return Database.getQueryLocator(query);  
    }
      
    /*
     Method Name: Execute
     Description: This method is used to process the TAC records that are passed from Start method.   
    */     
    global void Execute(Database.BatchableContext info, List<ABI_SFA_TerritoryAccountChange__c> tacList)
    {
	    if(tacList!=Null && tacList!=Empty){
			System.debug('@@@inside IF block');
			try {
				System.debug('@@@inside TRY block');
				Database.DeleteResult[] TAC_Dels = Database.delete(tacList);
			}
			catch (DmlException e) {
				System.debug('@@@ The following exception has occurred: ' + e.getMessage());
				ApexPages.addMessage(myMsg);
				ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,<strong>string.valueof(e)</strong>); 
			}
	    }
    }
	
	
    /*
     Method Name: Finish
     Description: This method is used to notify all relevant stakeholders via Email.      
    */       
    global void Finish(Database.BatchableContext info){ 

		String Email;
		List<ID> tacERId = new List<ID>();
		public void SendEmail() {
		for(TACEmailRecipients__c tacER: TACEmailRecipients__c.getAll().values());{
			tacERId.add(tacER.Id);
		}
		
		EmailTemplate et=[Select id from EmailTemplate where name = 'TAC_Notification' limit 1];

		Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
		mail.setTargetObjectIds(tacERId);
		mail.setSenderDisplayName('Acenture Support Team');
		mail.setTemplateId(et.id);
		Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
                 
    }   
}

 

I am a newbie in salesforce and eager to get familiar with this platform. Can someone clarify me as to why we begin writing a validation rule with OR, AND , NOT? Further more, why do we need to use them. Can we not simply use keywords like 'IF' to mention a condition, in oreder to validate our code or application module?
Thanks in advance.

I am a newbie in salesforce and eager to get familiar with this platform. Can someone clarify me as to why we begin writing a validation rule with OR, AND , NOT? Further more, why do we need to use them. Can we not simply use keywords like 'IF' to mention a condition, in oreder to validate our code or application module?
Thanks in advance.