Magulan Duraipandian

Salesforce

FIELD_INTEGRITY_EXCEPTION: An event can’t last longer than 14 days Salesforce exception

FIELD_INTEGRITY_EXCEPTION: An event can't last longer than 14 days exception occurs when the difference between Start Date/Time and End Date/Time is greater than 14 days. Sample Code: Event objEvent = new Event(Subject = 'Test', StartDateTime = System.now(), EndDateTime = system.now().addDays(15));      insert objEvent;  

Salesforce

Simple Batch Job Status email in batch’s finish method in Salesforce

Sample Code: global class SampleBatch Implements Database.Batchable <sObject> {                  global Database.queryLocator start( Database.BatchableContext bc ) {                  String SOQL = 'SELECT Id, Name FROM Account LIMIT 1';           return Database.getQueryLocator(SOQL);                  }              global void execute( Database.BatchableContext bc, List < sObject > scope ) {                  }              global void finish( Database.BatchableContext bc ) {                      AsyncApexJob a = [ SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedById                                FROM AsyncApexJob                               WHERE Id =: bc.getJobId() ];           Messaging.SingleEmailMessage batchEmail = new Messaging.SingleEmailMessage();           batchEmail.setTargetObjectId( a.CreatedById );           batchEmail.setSubject( 'Batch ' + a.Status );           batchEmail.setPlainTextBody( 'Jobs processed ' + a.JobItemsProcessed + ' with '+ a.NumberOfErrors + ' failures.' );           batchEmail.setSaveAsActivity( false );           Messaging.sendEmail( new Messaging.SingleEmailMessage[] {batchEmail} );                  }          }   ....