I need to get a list of available picklist fields in apex code, I attempted to get them like so:

// Products__c is a multi-select picklist custom activity field

And this works fine in anonymous apex execution but when I do it in my apex class, it wont compile giving me the following syntax error:

Method does not exist or incorrect signature: void getDescribe() from the type String

Why does it work fine in anonymous apex but not in my class? And how should I be getting picklist values in apex?


You have another symbol in the context of your class that is called Event and is shadowing the system Event class. Since that symbol has a property Products__c of type String, you may have a variable declaration like Event Event. For example, this code fails the same way in Anonymous Apex:

Event Event = null;


Remove the shadowing symbol and the code will work.

  • 1
    Alternatively reference the describe using Schema.Event.MyField__c.... – Adrian Larson Oct 1 '20 at 18:41
  • I do have a field event of type Event; are variables not case sensitive? Either way you seem to be right; Event was shadowed. – rosghub Oct 1 '20 at 19:24
  • 1
    The vast majority of Apex (including symbol references) is not case sensitive. – David Reed Oct 1 '20 at 19:31

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.