Searching Samples
In these examples, the values in the current object are used unless otherwise stated.
You can find the following search samples in this section:
- Searching for Child Accounts with Certain Posting Criteria
- Getting a List of Tasks Completed within a Certain Time Period
Searching for Child Accounts with Certain Posting Criteria
The following code searches for all accounts with the same parent account and a specific project set as their posting criteria.
Search Requirements |
Find all child accounts of the Matter XYZ Budget account that have a specific litigation record with the unique ID 7/15/2005-6548 set as their posting criteria. |
Search Criteria |
AND statement with the following qualifiers:
|
Sample Values |
System Field Attributes: Categories: Custom Field Attributes: |
Searching for Child Accounts with Certain Posting Criteria
// An example of building more complicated field paths AccountService accountService = platform.getAccountService(); // Search by the name of the parent account FieldPath parentAccountName = new FieldPath(Account.PARENT_ACCOUNT).add(Account.NAME); StringCriterion parentAccountNameCriterion = new StringCriterion(parentAccountName).equalTo("Matter XYZ Budget"); // Search by the number string of the project FieldPath projectNumberString = new FieldPath(AccountPostingCriteria.PROJECT).add(Project.NUMBER_STRING); StringCriterion projectNumberStringCriterion = new StringCriterion(projectNumberString).equalTo("7/15/2005-6548"); // Join the criteria together SearchCriteria criteria = new SearchCriteria(parentAccountNameCriterion, projectNumberStringCriterion); List<account> accounts = accountService.search(criteria);
Getting a List of Tasks Completed within a Certain Time Period
The following code gets a list of all tasks completed within the specified time period.
Search Requirements |
Find all tasks John Smith completed within the month of June 2005. |
Search Criteria |
AND statement with the following qualifiers:
|
Sample Values |
System Field Attributes: Categories: Custom Field Attributes: |
Searching for All Tasks Completed within a Certain Period
askService taskService = platform.getTaskService(); // Find tasks only for the given user UserCriterion userCriterion = new UserCriterion(Task.CURRENT_ASSIGNEE).equalTo(assignee); // Find tasks completed after the given start date and before the given end date DateCriterion dateCriterion = new DateCriterion(Task.COMPLETED_DATE).between(6/01/2005, 6/30/2005); // Join together the two criteria, using 'and' logic by default SearchCriteria searchCriteria = new SearchCriteria(userCriterion, dateCriterion); // Execute search and return results List<Task> tasks = taskService.search(searchCriteria);