Created
July 3, 2017 08:05
-
-
Save bandicoot86/c300fe8205374984c9aea85e01fdd8a7 to your computer and use it in GitHub Desktop.
Trigger for CustomEvent__c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger CustomEvent on CustomEvent__c(before insert, before update) { | |
CustomEventHelper h = new CustomEventHelper(); | |
for (CustomEvent__c e : trigger.new){ | |
if (e.StartDate__c == null || e.EndDate__c == null || (e.EndDate__c.getTime() - e.StartDate__c.getTime()) <=0){ | |
e.addError('Укажите корректные даты (непустые и дата окончания должна быть больше даты начала)'); | |
return; | |
} | |
if (!h.timeAv(e.StartDate__c, e.EndDate__c, e.Account__c, e.Id)){ | |
e.addError('Dates are already taken'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment