I use the below code sample to generate a recurring appointment from a customMicrosoft Dynamics CRM 2011 entity. This appointment is for display purposes only, it is not stored anywhere. It's just used to show when a certain employee would have to work according to his week schedule.
string vmstartuur = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmstartuur").Value.ToString(dutchCultureInfo);
string vmstartminuut = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmstartminuut").Value.ToString(dutchCultureInfo);
string vmeinduur = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmeinduur").Value.ToString(dutchCultureInfo);
string vmeindminuut = weekkalender.GetAttributeValue<OptionSetValue>("acm_" + weekdag + "vmeindminuut").Value.ToString(dutchCultureInfo);
DateTime vmstartDateTime = new DateTime(nextDateTime.Year, nextDateTime.Month, nextDateTime.Day, Convert.ToInt32(vmstartuur.Substring(Math.Max(0, vmstartuur.Length - 2))), Convert.ToInt32(vmstartminuut.Substring(Math.Max(0, vmstartminuut.Length - 2))), 0, DateTimeKind.Local);
DateTime vmendDateTime = new DateTime(nextDateTime.Year, nextDateTime.Month, nextDateTime.Day, Convert.ToInt32(vmeinduur.Substring(Math.Max(0, vmeinduur.Length - 2))), Convert.ToInt32(vmeindminuut.Substring(Math.Max(0, vmeindminuut.Length - 2))), 0, DateTimeKind.Local);
Telerik.Web.UI.Appointment vmrecurringAppointment = new Telerik.Web.UI.Appointment {Subject = weekdag + " voormiddag", ID= weekkalender.acm_werknemer.Name + weekdag + "_voormiddag", Start = vmstartDateTime, End = vmendDateTime};
RecurrenceRange vmrange = new RecurrenceRange {Start = vmrecurringAppointment.Start, EventDuration = vmrecurringAppointment.End - vmrecurringAppointment.Start, RecursUntil = contract.slfn_Eindeovereenkomst.GetValueOrDefault(DateTime.MaxValue), MaxOccurrences = Int32.MaxValue};
WeeklyRecurrenceRule vmWeeklyRecurrenceRule = new WeeklyRecurrenceRule(1, GetRecurrenceDay(dayOfWeek), vmrange);
vmrecurringAppointment.RecurrenceRule = vmWeeklyRecurrenceRule.ToString();
vmrecurringAppointment.RecurrenceState = RecurrenceState.Master;
appointmentList.Add(vmrecurringAppointment);
I generate anywhere from 2 to 14 recurring appointments, 2 for each day. I then use RadScheduler.DataSource
to bind appointmentList
to the RadScheduler.
the appointments are created, but the problem is that they don't recur. The first appointment does appear when it needs to, i.e. on the day his employment starts, but they don't repeat. I followed the Telerik guides for recurring appointments on http://www.telerik.com/help/aspnet-ajax/scheduler-working-with-recurring-appointments.html and on http://dotnetslackers.com/articles/aspnet/Using-Teleriks-Scheduler-Component.aspx, but I cannot figure out why it does not recur.
One of my coworkers helped me with this. Turns out there are 2 fields on the RadScheduler itself which trigger recurrence: DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"
. so my appointment generator code was fine.