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
agrassiagrassi 

Event - How to calculate maximum RecurrenceEndDateOnly

Hello everyone. We've a scheduled job that creates Event records. Particularly, some of these records are recurrent events. I've been receiving exceptions like the following when upserting records:

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Based on the frequency you selected, the end date cannot be after 18/05/2012.: End Date: [RecurrenceEndDateOnly]

 

 A couple of comments:

 

  • RecurrenceEndDateOnly is a required field (infinite recurrence isn't supported)
  • The maximum RecurrenceEndDateOnly depends, not only on the RecurrenceStartDateTime, but olso on the frequency kind, interval, and other values of the Event, as changing the recurrence details while creating a recurring event from the SF UI, will show a different max date if you click on the "calculate max end time" link (seems like event records are actually created for all instances, from time zero, nice)

 

I've been searching the docs for a way to determine the RecurrenceEndDateOnly max value, from within my Apex code, without success.

 

My question is: does anyone know how is this value calculated? Is there a class method or at least the formula to implement this on my side?

 

Thanks a lot,

 

Antonio

Best Answer chosen by agrassi
sfdcfoxsfdcfox
Depending on the type of series you are creating, the maximum number of occurrences is as follows:
  • Daily: 100
  • Weekly: 53
  • Monthly: 60
  • Yearly: 10

This is directly from the Help window...

 

In other words, if you create a daily-type event that occurs every third day, you can schedule it out a total of 300 days. Similarly, if you schedule a bi-weekly event, you can schedule it for 106 weeks (two years).

All Answers

frodriguez.adooxenfrodriguez.adooxen

I'm not quite sure about this, but maybe it the algorithm could be related to the amount of events created.

 

Thus, if you have like X events created with a top end date and you double the frequency, top end date should shrink to top end date / 2. I'd start by testing this

 

Is there any way to find out how the algorithm works anyway?

 

 

 

sfdcfoxsfdcfox
Depending on the type of series you are creating, the maximum number of occurrences is as follows:
  • Daily: 100
  • Weekly: 53
  • Monthly: 60
  • Yearly: 10

This is directly from the Help window...

 

In other words, if you create a daily-type event that occurs every third day, you can schedule it out a total of 300 days. Similarly, if you schedule a bi-weekly event, you can schedule it for 106 weeks (two years).

This was selected as the best answer
agrassiagrassi

Hello. Well, this is a step forward. Now, I should just write a method that interprets the recurrence fields, on its different combinations, for each of the recurrence types. Oh yes, this will be funny! "Nice".

 

Thanks sfdcfox,

 

Antonio

EmilyVEmilyV

Hi, I just created a recurring task :

frequency : weekly;

interval: every 3 weeks;

days: Sun, Tue, Wed;

 start date:5/2/2012

 

and the result is there are only 52 tasks..

 Does anyone out there know the exact algorithm of calculating the maximum end date?

Thanks in advance.