I created a simple Apex Trigger that shows an error message when user tries to create an event without adding any attendee. I created a custom label for error message and its translations in different languages. This works fine in all the languages except for one (Japanese). The record gets saved if the user's language is Japanese.
trigger Event_Attendee_Validation on Event (after insert, after update) {
Id ManagerRecordTypeId = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Manager').getRecordTypeId();
System.Debug('Event_Attendee_Validation Get RT ==> ' + ManagerRecordTypeId );
try{
for(Event event: Trigger.New){
if (event.IsChild == false && event.Type == 'Dual Day' && event.RecordTypeId == ManagerRecordTypeId) {
List<Event> childevents = [SELECT id From Event Where Task_Reference__c =:event.Task_Reference__c AND RecordTypeId =:event.RecordTypeId];
System.Debug('Event_Attendee_Validation Get Child Events ==> ' + childevents );
if (childevents.size() == 1){
Trigger.New[0].addError(Label.Dual_Day_Attendee_Error);
}
}
}
}
catch(Exception e){
System.debug('Event_Attendee_Validation ==> Error found inside for loop');
}
}