Skip to content

Bulk query grammar

Use this reference when a Query Check must run for several records in one request. Record Health Check groups supported queries so that it can evaluate the records together. Unsupported or ambiguous query shapes return a configuration error.

StrategyAuthored shapeScope behavior
SELFId = {!record.Id}Query the evaluated records and correlate by Id.
CHILD_DIRECTA direct field equals {!record.Id}Group rows by that lookup field.
CHILD_PATHA relationship path equals {!record.Id}Group rows by that relationship path.
TOKEN_INDIRECTA field equals another record token, including a token with options such as fallbackCollect token values, query once, and map rows back to the scope.
SCOPE_INVARIANTNo record tokenExecute once and reuse the result for every record.
ORDERED_PICK_IN_MEMORYA record-correlated query with outer ORDER BY fields and LIMIT N, whether the selected field matches the ordered field, differs from it, or is a relationship pathRemove the per-record limit, fetch bounded candidate rows in one scope query, and choose up to N ordered rows per record in Apex.
UNCLASSIFIEDUnsupported or ambiguous correlationReject the configuration; do not fall back to one query per record.

Ordered picks are never rewritten to generated MIN or MAX aggregates. The authored outer field selection and ordering remain intact, including a relationship selection such as Owner.Name. Negated correlation and non-equality correlation are unclassified. Ordered picks support multiple order fields and per-record limits greater than one. Without an outer ORDER BY, a correlated LIMIT greater than one is unsupported, except for a self query whose Id equality already restricts it to one record. Child-subquery ordering and limits do not select the outer strategy.

For example, WHERE Id = {!record.OwnerId fallback="005000000000001"} remains TOKEN_INDIRECT: token options do not make a record-correlated query scope-invariant. Use a real fallback value that is valid for the referenced field; the synthetic ID here documents grammar only.