8

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!

1
  • Welcome. And a very nicely written and researched question. Looking forward to your future contributions
    – Eric
    Commented Sep 13, 2018 at 6:38

1 Answer 1

3

Case.Comments is, as far as I'm aware, the only field that appears in normal describe calls but cannot be queried. This field apparently always describes as aggregateable=true, filterable=false, but I wouldn't necessarily say that this would be true for any other fields that are magic and can be described (but then again, I don't know any other fields that behave exactly like Comments). The other magic field that exists is Lead.Campaign. You can add it to a page layout, but it only appears when creating a new Lead, and can be used by Web-to-Lead, but otherwise does not appear in any standard describe calls that I'm aware of. You don't need to make an exception for this field, because it should never appear in your describe calls.

1
  • @LVB You're welcome!
    – sfdcfox
    Commented Sep 12, 2018 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .