Show/Hide Toolbars

Use AppointmentService when working with account records.

Whenever a Service operation requires AppointmentService, set up AppointmentService using the following code:

AppointmentService appointmentService = platform.getAppointmentService();

Creating an Appointment

The following sample creates an appointment. During appointment creation, you can use API interface methods to set objects in the appointment, including the start date, end date, and category.

// Retrieve the appointment service from the platform provided by the API

AppointmentService appointmentService = platform.getAppointmentService();

 

// Set up the initial required arguments to create a valid appointment

long fourDaysInMilliseconds = 86400000 * 4;

Date startOn = new Date();

Date endOn = new Date(startOn.getTime() + fourDaysInMilliseconds);

 

// Create a new appointment, passing in the arguments created above.

Appointment appointment = appointmentService("Appointment Subject", startOn, endOn);

 

// Any non-required fields on the appointment may be set or added now

appointment.setAllDay(true);

appointment.addCategory("APPT_CATE_CUST");

Updating an Appointment

The following sample updates an appointment. When you update an appointment, you can use API interface methods to set objects in the appointment, including the primary key, new attendees, and custom fields.

// Retrieve the appointment service from the platform provided by the API.

AppointmentService appointmentService = platform.getAppointmentService();

 

// Retrieve the desired appointment.

long primaryKeyForAppointment = 2;

Appointment appointment = appointmentService.read(primaryKeyForAppointment);

 

// Modify fields.

appointment.addAttendee(platform.getUserService().findUserByUsername("TestUser"), AttendanceType.WILL_ATTEND);

appointment.setBooleanFieldValue("customBooleanField", false);

Deleting an Appointment

The following sample deletes an appointment.

// Retrieve the appointment service from the platform provided by the API.

AppointmentService appointmentService = platform.getAppointmentService();

 

// An appointment can be deleted simply by passing in the primary key.

long primaryKeyForAppointment = 8;

appointmentService.delete(primaryKeyForAppointment);

 

// Or, you can pass in the appointment object.

Appointment appointment = appointmentService.read(primaryKeyForAppointment);

appointmentService.delete(appointment);

         

// In a rule, the delete will be committed when the rule completes.

// Otherwise, the delete will be committed immediately.

Searching for an Appointment

The following sample searches for all appointments in Room 101.

// Retrieve the appointment service from the platform provided by the API.

AppointmentService appointmentService = platform.getAppointmentService();

     

// Find all appointments located in Room 101

SearchCriteria criteria = new SearchCriteria(new StringCriterion(Appointment.LOCATION).equalTo("Room 101"));

     

// Sort results by start date

SearchParameters parameters = new SearchParameters(new SortField(Appointment.START_ON));

 

// Execute search and return results

return appointmentService.search(criteria, parameters);