The following sample creates an appointment record.
protected AppointmentRepository appointmentRepository;
private String createAppointment() throws Exception {
Date date = new Date();
AppointmentCreate appointment = new AppointmentCreate();
appointment.setSubject("Quarterly Meeting - Q2 2009");
appointment.setLocation("Build A-5");
appointment.setAssignedOn(date);
appointment.setStartOn(date);
appointment.setEndOn(date);
appointment.setAllDay(true);
appointment.setProjectUniqueKey("DISP_0003");
appointment.getAttendeeCreates().add(attendees);
appointment.getResourceCreates().add(resources);
appointment.getCategories().add(categories);
return appointmentRepository.insertAppointment(appointment);
}
private List<AttendeeCreate> attendeeCreate() {
List<AttendeeCreate> attendees = new List<AttendeeCreate>();
AttendeeCreate attendee1 = new AttendeeCreate();
attendee1.setUserUniqueKey("USER_1005");
attendee1.setAttendanceType(AttendanceType.WILL_ATTEND);
AttendeeCreate attendee2 = new AttendeeCreate();
attendee2.setUserUniqueKey("USER_1013");
attendee2.setAttendanceType(AttendanceType.TENTATIVE);
attendees.add(attendee1);
attendees.add(attendee2);
return attendees;
}
private List<AppointmentResourceCreate> appointmentResourceCreate()
{
List<AppointmentResourceCreate> appointmentResources = new List<AppointmentResourceCreate>();
AppointmentResourceCreate apptResource = new AppointmentResourceCreate();
//for this sample, it is assumed that for the Resource Type system lookup table, there is a table item with the unique key (or Tree position), "CRMA" (for Conference Room A)
apptResource.setTypeUniqueKey("CRMA");
appointmentResources.add(apptResource);
return appointmentResources;
}
private List<Category> categoryAdd() {
List<Category> categories = new ListArray<Category>();
Category cat = new Category();
//the next two lines identify a category and then add the category to the appointment record
cat.setUniqueKey("APPT_TRIA");
categories.add(cat);
return categories;
}