I'm trying a simple query for contacts to return all fields since this will be a general class for looking up contacts to be used in multiple areas. I tried using the new FIELDS function but keep getting an error stating

The SOQL FIELDS function is not supported with an unbounded set of fields in this API

This is the query in question and it is not an unbounded query.

Contact con =
                    [SELECT FIELDS(ALL),
                            (SELECT Id, AccountId, ContactId, IsActive, StartDate, EndDate, Role__c
                            FROM AccountContactRelations)
                    FROM Contact
                    WHERE Id = :recordId
                    LIMIT 1];

Has anyone else encountered this error or gotten the FIELDS(ALL) function to work?


FIELDS(ALL) works in the Developer Console ("Query" tab) and other APIs (REST, SOAP, etc), just not Apex. You can use FIELDS(STANDARD) or FIELDS(CUSTOM), but not both (or ALL). This is an Apex-only restriction to prevent blowing up heap limits.

  • I tried using FIELDS(CUSTOM) or FIELDS(STANDARD) and both still caused the same error. – byarsawich Apr 22 at 13:18
  • @byarsawich If using this in a class, make sure you're using a later API version (I think 52?) or you'll get a compile error. I know this works in my org, I've used it already. – sfdcfox Apr 22 at 13:20
  • Currently only FIELDS(STANDARD) is supported in Apex. See Brian Miller's comment to the OP. – digglemister 8 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.