Todo list
•
Version: 10
Some tooltip text!
• 2 minutes to read
• 2 minutes to read
Create a to-do
The following code sample will create a to-do (task ID = 6) due at the end of the current day. It applies to associate with ID 1.
Integer owner = 1; // associate.associate_id
NSContact myCompany;
myCompany.SetContactId(2); // contact.contact_id
DateTime deadline;
deadline.moveToDayEnd();
NSAppointmentAgent appointmentAgent;
NSAppointmentEntity newTask = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(6, owner);
newTask.SetDescription("Remember to turn off the lights when you leave the office.");
newTask.SetContact(myCompany);
newTask.SetAssignmentStatus(11);
newTask.SetEndDate(deadline);
newTask = appointmentAgent.SaveAppointmentEntity(newTask);
Note
While the to-do technically doesn't have a start time, that field will be set with a default value. For example, noon the current day. Don't assume that the start time is empty.
Complete a to-do
To mark a to-do as completed is essentially just to set the status to 3.
This example completes the to-do with ID 88, with end-time = now and start-time = 5 minutes ago.
DateTime start;
DateTime end;
NSAppointmentAgent appointmentAgent;
appointmentAgent.UpdateAppointment(88, start.addMin(-5), end, 3, 2, 5);
List overdue to-dos
DateTime now;
SearchEngine se;
se.addFields("appointment", "appointment_id,task_idx,status,endDate");
se.addCriteria("appointment.task_idx.record_type", "OperatorEquals", "6","OperatorAnd", 0);
se.addCriteria("appointment.status", "OperatorEquals", "1","OperatorAnd", 0);
se.addCriteria("appointment.endDate", "OperatorLt", now.toString(), "OperatorAnd", 0);
printLine(se.executeTextTable());
This sample will list all follow-ups of type 6 that have not been started and a deadline in the past.