I am writing a SOQL generator that grabs the list of readable fields for an object and creates a query to fetch the data. (Unrelated, but because "Why?" is often asked - this subroutine is part of a larger project that is going to allow me to use code to embed business logic on QuickText for surfacing suggested responses to my Customer Support Team.)
Condensing the actual query into a contrived minimum example here:
SELECT Id, Comments FROM Case WHERE Id = 'whateverId'
This query runs fine in test methods and the Execute Anonymous window in the Developer Console, but fails when running behind the scenes of a Visualforce Template with the following error:
No such column 'Comments' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
I came across this Stack Exchange Post wherein @sfdcfox mentions
I think there's literally only two of these fields, neither of which are documented, can't be described, can't be accessed by any API, etc.
Does anyone know the other field I should write in an exception for, or has anyone discovered a way to tell these fields apart from others? I compared the Describe result for Case.Comments to a couple of other fields and nothing really stood out (well...so far it is the only field I've discovered that isAggregatable() == true && isFilterable() == false but I'm not sure it that is merely a product of my current configuration).
Thanks for any insights!