You need to sign in to do that
Don't have an account?
agrassi
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
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
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?
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).
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
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.