Development questions

How does FIELDS(ALL), FIELDS(STANDARD), and FIELDS(CUSTOM) work in SOQL, and what are their limitations in Apex?

DevelopmentMediumDeloittePwCCapgemini

FIELDS() avoids listing every field:

  • FIELDS(STANDARD): all standard fields
  • FIELDS(CUSTOM): all custom fields
  • FIELDS(ALL): all fields
soql
SELECT FIELDS(ALL) FROM Account LIMIT 200

Limitations: FIELDS(ALL) and FIELDS(CUSTOM) require LIMIT 200 or less in Apex and most contexts (STANDARD has no such limit); you can't use them in subqueries or nested selects, and heavy use increases heap and query cost. For production code, selecting explicit fields is still recommended.

soqlfields