+ Start a Discussion
akshay desai 9akshay desai 9 

Is It possible to create a trigger on lightning calendar

Deepali KulshresthaDeepali Kulshrestha
Hi Akshay,
You can apply the trigger to an event and then associate that event to the calendar. Please go through the following sample codes as they may be helpful in solving your problem:
trigger SE_Request_Calendar_Trigger on SE_Request__c (after insert) {
     list<event> newEvents = new list<event>();
     string salesOpsCalendar = 'Ops Calendar';

     for (SE_Request__c seRequest : System.Trigger.new) {
         try {
             newEvents.add(new Event(
                 //  How do I convert 'Ops Calendar' to an id that owns our shared calendar?                 
                 OwnerId = ???, 

                 ActivityDateTime = seRequest.Date_of_Requested_Demo__c,

                 DurationInMinutes = 60,

                 // Local or on-site
                 Location = seRequest.Type_of_Demo__c,

                 Subject = 'Give a demo of ' + Products_for_Demo__c + ' for ' + seRequest.Requester_Name__c
         catch(Exception e){
     insert newEvents;
For adding the event to the calendar please go through the following code as it may be helpful to you:

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.