You need to sign in to do that
Don't have an account?
LeslieS
Creating a recurring event from a trigger
Hi,
I am trying to create an event record from a custom object that hold our class registrations.
2 problems at present. 1st is how do I link this to a public calendar, I can so far only get it to go to my calendar (user creating the class record).
2nd when trying to create an event which spans more than 1 day, I hit a problem with the the recurrencedayofweekmask value, an ideas what this should be?
Here's my code
Code:
trigger ClassTrigger on Class__c (after insert) { Map<String, Class__c> clasMap = new Map<String, Class__c>(); // after Classes are inserted List<Event> followupEvents = new List<Event>();// build list in memory for (Class__c clas : System.Trigger.new) { date t = clas.Start_Date__c; datetime xStartDate = DateTime.newInstance(t.year(),t.month(),t.day()); Event event = new Event( ActivityDate = clas.Start_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 = clas.Facility__c , IsAllDayEvent = TRUE, Event_Status__c = 'Not Started', Subject = 'Class trigger Event'); followupEvents.add(event); // add to list }
Thanks in advance.
Leslie
Solved them both.
Just realised that the query results function can be useful.
OwnerId is the id for each calendar.
RecurrenceDayofWeek mask needs to be 62. don't know why, just it has to be this.
Kind regards,
Leslie
I know this post is old, but I thought I'd add this comment in case anyone comes across it.
Per the API documentation, RecurrenceDayOfWeek is a "bit mask", meaning the various "bits" inside the number determine which days are checked.
Sunday - 1
Monday - 2
Tuesday - 4
Wednesday - 8
Thursday - 16
Friday - 32
Saturday - 64
So, to "check" Sunday and Monday, use "3" (1 + 2). For Saturday and Wednesday, use "72" ( 64 + 8 ). 62? 32 + 16 + 8 + 4 + 2 (Monday through Friday).