Clauses
A FOQL query is built from clauses in a fixed order: select … from … where … group by … order by … limit … offset. Only select and from are required.
SELECT#
The select list contains one or more comma-separated select items. Each item is either:
- a field path — a field name (
subject), or a dotted lookup traversal (vendor.name,vendor.moduleState.displayName); or - an aggregate —
sum(...),avg(...),min(...),max(...),count(...).
Each item may optionally be followed by as <alias> to rename the column in the response. See Aggregates & Aliases.
FROM#
A single module API name — the base module. In the reference query this is workorder. The base module determines which fields and lookups are addressable.
select id, subject from workorderWHERE#
A boolean condition tree. Group conditions with parentheses to control precedence and avoid ambiguity:
where (priority = 'Low' and status = 'Open') or totalCost > 5000The comparators allowed in a predicate depend on the field type of the left operand — see Field Types & Their Comparators.
WHERE constraints
- A
whereclause may contain a maximum of 25 criteria conditions. - Multi-line fields such as Description, Terms and Conditions, Comments, and similar cannot be used in the
wherecriteria.
GROUP BY#
A comma-separated list of fields. When the select list mixes aggregate functions with non-aggregated (scalar) fields, every scalar field must appear in group by.
select category, status, sum(totalCost)from workordergroup by category, statusORDER BY#
A comma-separated list of fields (or aliases), each optionally suffixed with asc (default) or desc. Sorting is applied left to right.
order by createdTime desc, id ascLIMIT / OFFSET#
limit caps the number of records returned in this call; offset skips that many records from the start of the result set. Together they implement pagination:
limit 100 offset 0 -- page 1limit 100 offset 100 -- page 2tip
A single call can return at most 2,000 records. See Limits & Validations.