The following sample reads child accounts of a parent account record. Identify the parent account by its unique key. In the sample, a complete list of account properties is provided but in your program, you can remove unnecessary properties to improve performance. Only the listed property values will be returned with the child accounts in the search results.
//for this example, it is assumed that you already know the target parent account record's unique key (where uniqueKey is a String variable)
protected AccountRepository accountRepository;
public void readChildAccounts() throws Exception {
List<Account> accounts = (List<Account>) accountRepository.readChildAccounts(uniqueKey, getPropertiesToRead());
}
private List<String> getPropertiesToRead() {
List<String> properties = new List<String>();
properties.add("createdBy");
properties.add("createdOn");
properties.add("modifiedBy");
properties.add("modifiedOn");
properties.add("name");
properties.add("allocated");
properties.add("allocationLimit");
properties.add("used");
properties.add("available");
properties.add("startOn");
properties.add("endOn");
properties.add("expensePercent");
properties.add("invoiceExpensePercent");
properties.add("invoiceTaskPercent");
properties.add("taskPercent");
properties.add("allowExpense");
properties.add("allowTask");
properties.add("allowInvoiceExpense");
properties.add("allowInvoiceTask");
properties.add("accountInvolvedType");
properties.add("accountVendorType");
properties.add("accountProjectType");
properties.add("accountOverdraftType");
properties.add("type");
properties.add("active");
properties.add("autoPost");
properties.add("categories");
properties.add("expenseCategory");
properties.add("taskCategory");
properties.add("projectCategory");
properties.add("invoiceExpenseCategory");
properties.add("invoiceTaskCategory");
properties.add("involved");
properties.add("project");
properties.add("vendor");
properties.add("parentAccount");
return properties;
}