RE: How to create recurring Sub Task under a recurring Main Task
Hello,
You can create relationship between Appointment and recurring Appointment.
Then use below code in your plugin/custom workflow to create recurring Appointment from c#
// Define an anonymous type to define the possible recurrence pattern values.
var RecurrencePatternTypes = new
{
Daily = 0,
Weekly = 1,
Monthly = 2,
Yearly = 3
};
// Define an anonymous type to define the possible values for days
// of the week
var DayOfWeek = new
{
Sunday = 0x01,
Monday = 0x02,
Tuesday = 0x04,
Wednesday = 0x08,
Thursday = 0x10,
Friday = 0x20,
Saturday = 0x40
};
// Define an anonymous type to define the possible values
// for the recurrence rule pattern end type.
var RecurrenceRulePatternEndType = new
{
NoEndDate = 1,
Occurrences = 2,
PatternEndDate = 3
};
// Create a recurring appointment
RecurringAppointmentMaster newRecurringAppointment = new RecurringAppointmentMaster
{
Subject = "Sample Recurring Appointment",
StartTime = DateTime.Now.AddHours(1),
EndTime = DateTime.Now.AddHours(2),
RecurrencePatternType = new OptionSetValue(RecurrencePatternTypes.Weekly),
Interval = 1,
DaysOfWeekMask = DayOfWeek.Thursday,
PatternStartDate = DateTime.Today,
Occurrences = 10,
PatternEndType = new OptionSetValue(RecurrenceRulePatternEndType.Occurrences)
};
_recurringAppointmentMasterId = _serviceProxy.Create(newRecurringAppointment);
Then You can add subgrid of RecurringAppointment on Appointment to show sub tasks.
Make sure you also set lookup field which got created from custom relationship.
Code is available in CRM SDK - D:\CRM Tools\Dynamics 365\SDK\SampleCode\CS\BusinessDataModel\ScheduleAndAppointment
Please mark my answer verified if i were helpful