I'm in a test org where I've installed my managed package. I have a javascript button that is utilizing the AJAX Toolkit to get the namespace dynamically but its not working in this org (it works fine in others) I'm getting the error:

..invalid type sobject type ApexClass is not supported...

The error is verbose than that but thats the general message.

Here's the offending part of the button javascript:

var queryResult = sforce.connection.query("SELECT namespaceprefix FROM ApexClass WHERE name='Ctl_Form' LIMIT 1"); 

This works fine in other orgs, any idea what setting or configuration might not allow this? I'm logged in a a System Admin.

I also tested running a SOQL query against ApexClass in the dev console and that ran fine.

  • 2
    is this a Group /Professional/personal edition org ?
    – Rao
    Feb 5, 2014 at 23:17
  • 1
    That was my first thought... sounds like an org where Apex isn't available.
    – Matt Lacey
    Feb 5, 2014 at 23:32
  • Its an EE org provisioned from the Partner Portal. If Apex wasn't available I wouldn't be able to run the SOQL query in the Dev Console right? I also double checked and I can create an Apex class in the org directly.
    – Phil B
    Feb 6, 2014 at 14:26

3 Answers 3


So it turns out when the package was originally installed (months ago), there were API restrictions placed on the package. I had just pushed out an upgrade this time. Those API restrictions weren't allowing access to the ApexClass object from the AJAX toolkit.

  • 1
    Ah yes, I love that API restrictions always remove access to system objects, and the only way to work with them is to totally turn off API restrictions. Feb 6, 2014 at 22:16

The user needs "View Setup and Configuration" permission to query the ApexClass object.


Go to Setup, type "users" in Quick Find text box. Check the User Profile name you're using to access API. Edit the profile and set the permission Author Apex. This should fix it.

You must log in to answer this question.

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