Each TeamConnect Web Service provides a method for searching records by an object type and by additional search criteria. The general form of the method is readObjectsByCriteria (SearchCriteria criteria, int limit, List<String> properties). For example, for the Contact repository the corresponding method is readContactsByCriteria (SearchCriteria criteria, int limit, List<String> properties). A list of record objects that meet the search criteria is returned with only the specified property values.
Note: When defining the list of property values to return, remember that some of the entity properties are objects. In these cases you need to explicitly specify the property of the property (where the property type is object) to return. For an example, see Code Snippet for readContactsByCriteria (specify return properties of contact property of type object).
The search method provided in TeamConnect® Enterprise Web Services is designed to search among a moderate number of records (for example, if you expect less than 100 records in the search results). For the limit parameter, it is recommended to enter 100 as the maximum number of records to return. If you need to search across a larger volume of records, you may want to use the application UI.
A detailed description of how to define search criteria is provided below. The properties parameter in the readContactsByCriteria method is defined and used in the same way as for the readContact method (described above).
You need to define search criteria. From the \types directory you need to use the FieldSearchClause object to hold your search criteria. For each search, you need to define the following:
•one or more field criterion
Field criterion are defined according to the data type for the field you are searching. For example, you can define field criterion for comparing a field that is a String type using the StringComparator and StringFieldCriterion objects.
•an operator (for example, AND or OR) that defines how the field criterion are combined in the search if you are using multiple field criteria
Each field criterion is made up of three parts: a field path (pointer to the database table/column that you will query), a comparator (defines how you are comparing the database record values against a literal value), and a literal value. The parts of a field criterion are illustrated in the following search fields screenshot.
Example of a Contact Search by First Name
In the contact search screenshot, First Name (1.) corresponds to the field path; Equal To (2.) corresponds to the comparator; and John (3.) is the literal value. Corresponding sample code for search criteria is in the Code Snippet section. See Searching for Contacts for a JAVA example of how to set search criteria.
When defining search criteria where you want to search for a record by a custom field value, you need to define the searchKeyPath using the following format: TCCategoryTreePosition + "__" + detailFieldName (where there are two underscores, "_", between the tree position and detail field name).
For example, fieldPathExpression.setSearchKeyPath("DISP__CorrectiveActionDeadlineDI");
For a more detailed example, see Code Snippet for readContactsByCriteria (search by custom field value).
Note: If you will search by a custom field value that is associated with a child category, then the TCCategoryTreePosition should be constructed like parentObjectRootCategoryTreePosition + "_" + childCategoryTreePosition "__" + detailFieldName (where there is a single underscore, "_", between the root category tree position and its child category tree positions. Also note that an object's root category tree position is the same as the object definition's unique code.