Skip to main content

Hi,


On the project I’m currently working on I need to implement the SF standard functionality to create recurring events.
I already checked out this thread from Matt but I need to use the standard SF Event object, not a custom one.
In addition I need to include invitees (also SF standard stuff) but I don’t really have clue how to implement this. Do I need an additional custom object for that or is there a SF standard object that has to be included as well?

Has any of you guys already implemented something like or similar to this?
Any help is much appreciated.

Cheers

Hey David - here’s a quick run through of what I did when I implemented this: Events and Tasks are based on the Activities objects. SF gives you a bunch of ‘Recurrence’ fields that you can use to reverse engineer the native SF functionality. ISRECURRENCE is a check box field that lets SF know this is Recurrence Activity. Example: True/False RECURRENCESTARTDATEONLY is a date field and is when you want to start the Recurrence. Example: mm/dd/yyyy RECURRENCEENDDATEONLY is a date field and is when you want to end the Recurrence. Example: mm/dd/yyyy RECURRENCETIMEZONESIDKEY is what time zone the user is in. An example of this is “America/New_York”. RECURRENCETYPE is what type of Recurrence we are doing. Some examples are (RecursEveryWeekday, RecursWeekly, RecursMonthly, RecursYearly, and RecursDaily. RECURRENCEINTERVAL is how often the Recurrence happens. This is a number field and would show how many times the activity will repeat. Example: 1 would mean the activity would repeat once. RECURRENCEDAYOFWEEKMASK - The day or days of the week on which the task repeats. This field contains a bitmask. For each day of the week, the values are as follows Sunday = 1 Monday = 2 Tuesday = 4 Wednesday = 8 Thursday = 16 Friday = 32 Saturday = 64 RECURRENCEDAYOFMONTH - The day of the month on which the task repeats: 1 would be for the 1st day of the month. RECURRENCEINSTANCE - The interval between recurring tasks. Example if you want the recurrence to start on the 1st day of every month you would enter “First”. This is used if you are creating the recurrence activity yearly RECURRENCEMONTHOFYEAR - The month of the year on which the task repeats. Example: June, July If you search for these fields, you’ll probably find the additional guidance you’ll need.


Hi Griffin,

Thanks for your reply.
I did a lot of try-and-error in the meantime and found out a couple of interesting and a lot of weird things about the recurrences.
Nevertheless the events are saving correctly with the recurrence but I’m still confused about some of the fields.
I’ll do some more try-and-error and will post an understandable guide of the event recurrences.

Cheers


Ok, I finally got it working correctly and fully functional (to the level of what we need, meaning not every functionality needed to be implemented).


I am now able to create recurring events on workdays every 1- 4 week, on selected weekdays every 1 - 4 weeks, monthly at the n’th-day of each month and finally every n’th day of the n’th month of each year.


And here’s how to store the events in SalesForce correctly (meaning they are created as recurring events):


Necessary SalesForce fields and their explanation:



  1. RecurrenceType -> the type of the recurrence




  2. RecurrenceDayOfWeekMask -> a bitmask of the days (see Griffins post above for the exact values). Before saving you have to add up each selected day value and store it in that field (e.g. Monday + Tuesday = 6, Wednesday + Saturday = 72, etc…)




  3. RecurrenceInterval -> this is actually misleading documented: it’s not the value of how many times the event repeats, it’s the value of how often it should repeat (e.g. 1 means every week/month, 2 means every 2nd week/month, etc…). One really misleading documentation entry…




  4. RecurrenceDayOfMonth -> the day of the month (1 - 31 independent of the month, if you enter 31 on february or other months that only have 30 days, the date is set to the last day of the month (28th or 29th).




  5. RecurrenceMonthOfYear -> a picklist containing all the month names



Field setup: I created a picklist (UI-Only Fields) for most of the above fields (to customize/limit the functionality and serve a better UX):



  1. RecurrenceType (picklist) -> containing the values “RecursEveryWeekday”, “RecursWeekly”, “RecursMonthly” and “RecursYearly”




  2. RecurrenceDayOfWeekMask (multi-picklist) -> containing the values and the names for each day (see Griffins post above)




  3. RecurrenceInterval (picklist) -> I actually made 2 picklists, one for weeks (each week to each 4th week) and one for months (each month to each 11th month) containing the according values




  4. RecurrenceDayOfMonth (picklist) -> I created this picklist in order to give the user a nice and easy way to select the day (only the number), the SalesForce field is an Integer field, which can and will confuse users.




  5. RecurrenceMonthOfYear (picklist) -> not necessary but I had to create it because of translation issues.

    PageBuilder setup:



I used a Field editor with column sets as below. All the fields (including Start and End) are only rendered if “Create Recurrence” is true:


  1. RecurrenceType -> rendered as radio buttons, no rendering conditions

  2. RecurrenceIntervalWeek -> rendered as picklist, only rendering if RecurrenceType is “RecursWeekly”

  3. RecurrenceDayOfWeekMask -> rendered as checkboxes, only rendering if RecurrenceType is “RecursWeekly”

  4. RecurrenceDayOfMonth -> rendered as picklist, only rendering if RecurrenceType is either “RecursMonthly” or “RecursYearly”

  5. RecurrenceIntervalMonth -> rendered as picklist, only rendering if RecurrenceType is “RecursMonthly”

  6. RecurrenceMonthOfYear -> rendered as picklist, only rendering if RecurrenceType is “RecursYearly”

I added a class to field 5 and 6 in order to hide the label (looks cleaner without it).


I also set some of the fields required (do as you wish/what you think is best, SalesForce/Skuid will prompt you with an error anyways 🙂 ).


Before saving the event, you need to adapt the selected values into the model. I used a snippet for that (do not be confused by the naming of the fields, it’s not the same as described above. If you don’t understand it, let me know I will then either explain it to you or make a better version of it):


var $ = skuid.$, eventModel = skuid.$M('Event'), eventRow = eventModel.getFirstRow(), updates = {}; updates.RecurrenceType = eventRow.recurrenceTypeMask; if(eventRow.recurrenceTypeMask == "RecursEveryWeekday") { //sum of all weekdays updates.RecurrenceDayOfWeekMask = 62; //interval has to be null updates.RecurrenceInterval = null; } else if(eventRow.recurrenceTypeMask == "RecursWeekly"){ //set the field to 0 updates.RecurrenceDayOfWeekMask = 0; updates.RecurrenceInterval = parseInt(eventRow.weekMonthMask); //if the user selected the weekdays if(eventRow.weekDayMask){ //split the values by ; (its a multi-picklist value) and loop over them $.each(eventRow.weekDayMask.split(';'), function(index, value){ //add up the values of the selected days updates.RecurrenceDayOfWeekMask += parseInt(value); }); } } else if(eventRow.recurrenceTypeMask == "RecursMonthly"){ //set the day of the month updates.RecurrenceDayOfMonth = parseInt(eventRow.recurrenceDayOfMonthMask); //set the interval updates.RecurrenceInterval = parseInt(eventRow.recurrenceIntervalMonthMask); } else if(eventRow.recurrenceTypeMask == "RecursYearly") { //set the month updates.RecurrenceMonthOfYear = eventRow.recurrenceMonthOfYearMask; //set the year updates.RecurrenceDayOfMonth = parseInt(eventRow.recurrenceDayOfMonthMask); //interval has to be null updates.RecurrenceInterval = null; } eventModel.updateRow(eventRow, updates);

The final result (don’t judge the design, it’s not nearly finished yet):






I hope this helps anyone for the future.


Cheers


Thanks for sharing how to do this, David and Griffin! I’m sure this will come in handy for other people as well 🙂


Well done


Thank you so much!!!