records_count()
Count how many records match a set of filters.
Syntax
records_count(table, filters?)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
table |
string or number | yes | The table's name, its database table name, or its numeric table id. Read the id from $table at run time (for example $table["fields"]["client"]["lookup_table"]); never type one into your code, because table ids change when a workspace is copied. A table whose name happens to be a number always wins over the table with that id. |
filters |
array | no | Filter conditions — see records_query(). Omit for a total count. |
Returns
An integer count.
Example
$open = records_count("tickets", [
["field" => "status", "op" => "!=", "value" => "closed"]
]);
if ( $open > 50 ) {
record_comment("dashboards", $record["_meta"]["id"], "Backlog over 50: " . $open);
}
Example output
63
Notes
- Counting is capped at 1000 — use it for thresholds and gating, not exact totals on very large tables.
See also: records_query()