Finding All Case Objects of a Particular Type
From within a script, use the findAll method on the appropriate case access class to return a list of all case references for that case class.
| Method syntax | Description |
|---|---|
| findAll() | Returns a single list containing all case references for the case class. |
| findAll(index,pageSize) | Returns a paginated list of all case references for the case class. |
where:
- index is the (zero-based) number of the first record to return in a paginated list.
- pageSize is the number of records to return in each page of a paginated list. A value of -1 means return all records.
Examples
This example shows how to get a list of all Customer case references.
// Get a list of all Customer case references
customerReferenceList = cac_com_example_ordermodel_Customer.findAll();
// You can now read the list of case references to obtain a list of corresponding Customer case data objects.
var customerList = cac_com_example_ordermodel_Customer.read(customerReferenceList);
// Then process those customers.
for (var ix = 0; ix < customerList.size(); ix++)
{
var customer = customerList.get(ix);
// process customer objects…
// …
}
This example shows how to use a paginated list to iterate through the returned list of customers and find the one with the largest number of orders.
var maxOrderCount = 0;
var name = "";
var index = 0;
var pageSize = 100;
while (true) {
var custRefs = cac_com_example_ordermodel_Customer.findAll(index, pageSize);
for (var ix = 0; ix < custRefs.size(); ix++) {
var customerRef = custRefs.get(ix);
var count = customerRef.getOrdersRefs().size();
var customer = customerRef.readCustomer();
if (count > maxOrderCount) {
maxOrderCount = count;
name = customer.name;
}
}
if (custRefs.hasMoreResults) {
index += pageSize;
} else {
break;
}
}
Copyright © Cloud Software Group, Inc. All rights reserved.
