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(caseType, index, pageSize) Returns a paginated list of all case references for the case class.

where:

  • caseType is the parent ID followed by the case class name. For example, 'com.example.carapplication.Customer'.
  • 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
	data.customerReferenceList = bpm.caseData.findAll('com.example.ordermodel.Customer', 0, 100);

	// You can now read the list of case references to obtain a list of corresponding Customer case data objects.
	var customerList = bpm.caseData.read(data.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 = bpm.caseData.findAll('com.example.ordermodel.customer', 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;
		}
	}