The following sample searches for one or more appointment records and returns the specified property values. For this sample, it is assumed there is one or more appointments already existing with a subject String field value equal to subject.
protected AppointmentRepository appointmentRepository;
private List<Appointment> test_readAppointmentsByCriteria() throws
Exception {
// Criterion for appointment searching
StringFieldCriterion fieldCriterion = new StringFieldCriterion();
fieldCriterion.setComparator(StringComparator.EQUALS_ENFORCE_CASE);
LegacySearchFieldPathExpression fieldPathExpression = new LegacySearchFieldPathExpression();
fieldPathExpression.setSearchKeyPath("subject");
fieldCriterion.setFieldPath(fieldPathExpression);
fieldCriterion.getValue().add("Client meeting");
FieldSearchClause searchCriteria = new FieldSearchClause();
searchCriteria.setOperator(LogicOperator.AND);
searchCriteria.getCriteria().add(fieldCriterion);
appointments = appointmentRepository.readAappointmentsByCriteria(searchCriteria, 100, getPropertiesToRead());
}
private List<String> getPropertiesToRead() {
List<String> props = new List<String>();
//the list of all available properties displays below but to increase efficiency in your searches, you can omit unnecessary properties from your application and those values will not be returned
props.add("uniqueKey");
props.add("version");
props.add("subject");
props.add("categories");
props.add("createdOn");
props.add("createdBy");
props.add("modifiedBy");
props.add("modifiedOn");
props.add("location");
props.add("startOn");
props.add("endOn");
props.add("allDay");
props.add("project");
props.add("attendees");
props.add("resources");
props.add("categories");
return props;
}