| Argument | Description | Types / Required |
| dataId | The resource ID returned by Data.open, or a dictionary name. | number, string
recommended |
| status | Options for the status of the cases to query.
The default value is "notDeletedOnly". | string
not required |
| filter | Options for how the queried data should be filtered. | object
not required |
The data source is identified using
dataId. If specified as a string, it references the data source that is connected to a dictionary that is part of an application. If specified as a number, it is processed as a
resource ID returned by
Data.open. This typically references non-application data sources. While optional, this should generally be specified explicitly. (If there is only one data source open, the resource ID can be calculated implicitly.)
The string argument status can be used to filter cases by "status":
- "all": Do not apply a filter, processing all cases, including deleted cases.
- "notDeletedOnly": Process only non-deleted cases.
- "partialsOnly": Process only non-deleted cases that are partially saved.
- "duplicatesOnly": Process only non-deleted cases where there are at least two cases with the same key.
The argument filter, an object, can be used to further filter cases. The filters include two primary values: operator and value:
| Operator | Description |
| "startswith" | Only consider cases with a key starting with the specified value. |
| "<" | Only consider cases with a key that is less than the specified value. |
| "<=" | Only consider cases with a key that is less than or equal to the specified value. |
| ">=" | Only consider cases with a key that is greater than or equal to the specified value. |
| ">" | Only consider cases with a key that is greater than the specified value. |
Alternatively, by defining
type as
"position", these checks (other than
"startswith") will apply to the "
position" of a case. The type is
"key" by default.
The action returns the numbers of cases that match the filters.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- The data source ID is not valid.
- There is an error interacting with the data source.
const dataId = /* retrieved from a call to CS.Data.open */;
// count the number of non-deleted partial cases
CS.Data.countCases({
dataId: dataId,
status: "partialsOnly"
});
// count the number of non-deleted cases with a key starting with "01"
CS.Data.countCases({
dataId: dataId,
filter: {
operator: "startswith",
value: "01"
}
});
// count the number of cases, including deleted cases, with a key >= "01"
CS.Data.countCases({
dataId: dataId,
status: "all",
filter: {
operator: ">=",
value: "01"
}
});