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
CTISJH1CTISJH1 

Adding a public event

I am trying to create a trigger that will take information from a sObject we have created and use it to create a new public event. I found some code for a recurring event and I figured I could tweak it to create the events I am aiming for. The problem is that even though the code compiles fine, when I create a new record in our sObject I can not find the event that was supposed to be created. What am I missing?

 

 

trigger aClassTrigger on LGA__c (after insert) {
Map<String, LGA__c> clasMap = new Map<String, LGA__c>();
// after LGA are inserted
   List<Event> lgaEvents = new List<Event>();// build list in memory
   for (LGA__c clas : System.Trigger.new) {
    date t = clas.LGA_Date__c;
          datetime xStartDate = DateTime.newInstance(t.year(),t.month(),t.day());
   Event event = new Event(
    ActivityDate = clas.LGA_Date__c ,
    RecurrenceEndDateOnly = clas.End_Date__c ,
    RecurrenceStartDateTime = xStartDate,
    RecurrenceType = 'RecursEveryWeekday',
    RecurrenceDayofWeekMask = 1,
    IsRecurrence = TRUE,
    Description = 'Class Event.',
    Event_Type__c = 'Customer Training',
    Call_Objective__c = 'training',
    Location = 'here',
    IsAllDayEvent = TRUE,
    Event_Status__c = 'Not Started',
    Subject = 'Class trigger Event');
    lgaEvents.add(event);  // add to list
   }

}

Best Answer chosen by Admin (Salesforce Developers) 
BrianWKBrianWK

Where are you actually creating the event? I see you creating a list, creating a new object of event and adding it to the list, but no where do I see an Insert dml command.

 

Try adding "insert lgaEvents;" to your trigger. That will actually create the invite as a record instead of a temporary file.

All Answers

BrianWKBrianWK

Where are you actually creating the event? I see you creating a list, creating a new object of event and adding it to the list, but no where do I see an Insert dml command.

 

Try adding "insert lgaEvents;" to your trigger. That will actually create the invite as a record instead of a temporary file.

This was selected as the best answer
CTISJH1CTISJH1

That did it. I have a lot to learn when it comes to Apex :) Thanks for the help.