• Alcides Rojas 1
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Greetings

Recently, I had to review a trigger that was made to avoid the overlapping of time when a new event is created. That trigger is not working (still is possible to do overlapping) I cant understand what is happening with that trigger. Please if anybody can help me with I will be grateful. The triiger is the following (was designed for the Event Object):

 

trigger DateCheckerTrigger on Event (before insert) {

    for ( Event  J : Trigger.New ) {

        List<Event> eventList = [select id from event where ActivityDate= :J.ActivityDate and StartDateTime< :J.StartDateTime and EndDateTime> :J.StartDateTime and WhoId= :J.WhoId];
        
        if(eventList.size()>0){
            J.adderror('Ya existe una visita programada a la misma hora');
        }
    }
}


Thanks for your attention.

Best Regards