function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jimmy MaoJimmy Mao 

Contact.SObjectType

hi,
Contact is regarding as a standard salesforce object, like Account, Lead etc. But when I try to get Contact.SObjectType, it shows error " Error: Compile Error: Invalid field SObjectType for SObject Contact". I tried other standard object Account and Lead, Account.SObjectType Lead.SObjectType, they won't return any error.

Is there difference between Contact with other standard object, or there would be some kind of version support this?
SKolakanSKolakan
Contact Type does resolve correctly. Just execute this in your execute anonymous 
System.debug('contact type:' + contact.SObjectType);
Jimmy MaoJimmy Mao
Thanks Sreeni. 
It's ok when I debug on execute window, also ok in a new class. There's the managed class associated with a package, and the error turns out there. Anyone knows something about that?
Eric SwinehartEric Swinehart
I ran into this problem today and noticed Contact.SObjectType was fine in one method but gave me the syntax error in another. I had a variable named "contact" elsewhere in the method which seems to be source of the compiler confusion. Changing the name of the variable to something else allowed me to save the class file.