Create repeating follow-ups
•
Version: 10
Some tooltip text!
• 3 minutes to read
• 3 minutes to read
- Create the appointment, call, meeting, or task as usual.
- Set recurrence info.
- Save the follow-up.
NSAppointmentAgent appointmentAgent;
NSAppointmentEntity newAppointment = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(7, 1);
newAppointment.SetDescription("Morning coffee");
NSRecurrenceInfo r = appointmentAgent.CreateDefaultRecurrence();
newAppointment.SetRecurrence(r);
newAppointment = appointmentAgent.SaveAppointmentEntity(newAppointment);
NSRecurrenceInfo CreateDefaultRecurrence()
NSAppointmentAgent appointmentAgent;
NSRecurrenceInfo r = appointmentAgent.CreateDefaultRecurrence();
printLine("Start: " + r.GetStartDate().toString());
printLine("Pattern: " + r.GetPattern().toString());
Tip
Alternatively use CreateDefaultRecurrenceByDate()
to the date that the recurring pattern should start.
Repeat at standard interval
To repeat at a standard interval (daily, weekly, monthly, yearly), call SetPattern()
with value [1-4]. See the reference section for details.
This example creates a 10-minute daily coffee break at 14:00 starting August 1st.
DateTime start = String("2020-08-01 14:00").toDateTime();
DateTime end = start;
end.addMin(10);
DateTime stop = start;
stop.moveToYearEnd();
NSAppointmentAgent appointmentAgent;
NSAppointmentEntity newAppointment = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(7, 1);
newAppointment.SetStartDate(start);
newAppointment.SetEndDate(end);
newAppointment.SetDescription("coffee break");
NSRecurrenceInfo r = appointmentAgent.CreateDefaultRecurrence();
r.SetPattern(1);
r.SetIsRecurrence(true);
r.SetRecurrenceEndType(1);
r.SetStartDate(start);
r.SetEndDate(stop);
NSRecurrenceDayPattern p;
p.SetPattern(1);
r.SetDayPattern(p);
newAppointment.SetRecurrence(r);
newAppointment = appointmentAgent.SaveAppointmentEntity(newAppointment);
Repeat at user-defined interval
Example: hourly reminders throughout the working day
NSRecurrenceInfo r;
r.SetPattern(5);
DateTime now;
NSRecurrenceDate[] dates;
for (Integer i = 0; i < 8; +++) {
NSRecurrenceDate d;
d.SetDate(now);
d.SetDescription("Stretch and have some water");
dates.pushBack(d);
d.addHour(1);
}
r.SetDates(dates);
Repeat at selected dates
You can also manually create a list of selected dates that don't follow a pattern.
NSRecurrenceInfo r;
r.SetPattern(5);
DateTime[] selectedDates;
selectedDates.pushBack(String("2020-08-17").toDateTime());
selectedDates.pushBack(String("2020-09-21").toDateTime());
selectedDates.pushBack(String("2020-11-16").toDateTime());
selectedDates.pushBack(String("2021-01-04").toDateTime());
NSRecurrenceDate[] dates;
for (Integer i = 0; i < selectedDates.length(); +++) {
NSRecurrenceDate d;
d.SetDate(selectedDates[i]);
d.SetDescription("Planning - daycare closed");
dates.pushBack(d);
}
r.SetDates(dates);
Repeat until
You can choose to stop after a specific number of times or after a specific date.
Repeat 10 times:
NSRecurrenceInfo r;
r.SetRecurrenceEndType(2);
r.SetRecurrenceCounter(10);
Repeat until end of next month:
DateTime d;
d.moveToMonthEnd();
d.addMonth(1);
NSRecurrenceInfo r;
r.SetRecurrenceEndType(1);
r.SetEndDate(d);
Related topics
NSRecurrenceInfo
Field | Type | Description |
---|---|---|
IsRecurrence | Bool | whether it is a repeating follow-up |
RecurrenceId | Integer | unique ID of the rule |
RecurrenceEndType | Integer | 0 = unknown 1 = end by date 2 = end after n repetitions |
RecurrenceCounter | Integer | the number of repetitions used only when the end is calculated from a count |
StartDate | DateTime | when repetition starts |
EndDate | DateTime | when repetition ends used only when the end is calculated from a date |
Dates | NSRecurrenceDate[] | List of all dates the follow-up occurs wraps a DateTime |
Pattern | Integer | the main pattern of recurrence |