• frodriguez.adooxen
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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