Skip to content

Instantly share code, notes, and snippets.

@bandicoot86
Created July 3, 2017 08:06
Show Gist options
  • Save bandicoot86/5458f980ac9b13327416b0e5e2e7a5d5 to your computer and use it in GitHub Desktop.
Save bandicoot86/5458f980ac9b13327416b0e5e2e7a5d5 to your computer and use it in GitHub Desktop.
Custom event helper to do the logic
public class CustomEventHelper {
public Boolean timeAv(DateTime s, DateTime e, Id accId, Id cid) {
Boolean allowed = false;
try {
Long c = [SELECT count() FROM CustomEvent__c WHERE Account__c=:accId
AND
(
(StartDate__c <=:s AND EndDate__c >=:s) OR
(StartDate__c <=:e AND EndDate__c >=:e) OR
(StartDate__c>=:s AND EndDate__c<=:e)
)
AND Id<>:cid];
allowed = c == 0;
} catch (Exception ex){
system.debug('Error ' + ex.getMessage());
}
return allowed;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment