function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Syed Moin PashaSyed Moin Pasha 

How do we fetch the Attendee event list on the before insert in Event Trigger in salesforce

I'm working on the Event object in salesforce once the event get's inserted into salesforce it should create a record for me. It is working fine when the user create an events without attendee but once the user create an event with Attendee list it is not creating an record for the attendee. Below is the code for the creation of record. Please assist me with this.

Trigger eventUpdate on Event(Before Insert) { List < Time_Off__c > TimeOffs2Upsert = new List < Time_Off__c > (); for (Event evt: Trigger.new) { Time_Off__c TO = TimeOffMAP.containsKey(evt.WhatId) ? TimeOffMAP.get(evt.WhatId) : new Time_Off__c(); String STime = String.valueOf(evt.StartDateTime).split(' ')[1]; String ETime = String.valueOf(evt.EndDateTime).split(' ')[1]; Date StartDate = Date.newInstance(evt.StartDateTime.Year(), evt.StartDateTime.Month(), evt.StartDateTime.Day()); Date EndDate = Date.newInstance(evt.EndDateTime.Year(), evt.EndDateTime.Month(), evt.EndDateTime.Day()); Time StartTime = Time.newInstance(Integer.valueOf(STime.split(':')[0]), Integer.valueOf(STime.split(':')[1]), 0, 0); Time EndTime = Time.newInstance(Integer.valueOf(ETime.split(':')[0]), Integer.valueOf(ETime.split(':')[1]), 0, 0); TO.Start_Date__c = StartDate; TO.End_Date__c = EndDate; TO.Start_Time__c = StartTime; TO.End_Time__c = EndTime; TO.Type__c = 'Other'; TO.Reason__c = evt.Subject; TO.User__c = evt.OwnerId; TimeOffs2Upsert.add(TO); } if(TimeOffs2Upsert.size()>0) upsert TimeOffs2Upsert; }

Thanks
SwethaSwetha (Salesforce Developers) 
Hi Syed,
When the user creates an event with an Attendee list is it throwing an error message when the record is not created for the attendee?

Also code is not well-formatted to be able to understand well. Would you be able to format the code snippet?Thanks