This function is available in API version 51.0 and later.
We have three ways to get Fields dynamically.
FIELDS(ALL)—to select all the fields of an object
FIELDS(CUSTOM)—to select all the custom fields of an object.
FIELDS(STANDARD)—to select all the standard fields of an object.
SELECT FIELDS(CUSTOM) FROM Account LIMIT 200
With this query, you can pull all of the custom fields on the Account object alongside some standard fields like Name or Id. Likewise, you could employ:
SELECT FIELDS(standard) FROM Account LIMIT 10
With this query, you can pull all of the standard fields on the Account object .
SELECT FIELDS(all) FROM student__c LIMIT 5
As you can see above first of all we are getting all the standard fields and at the end we are getting all the custom fields as well.
As you can see FIELDS() is a convenient feature that can simplify data exploration use cases.
The function can also accelerate platform integrations by promoting loose-coupling between the code developers write and the use cases at-hand while also improving maintainability of the software