[SalesForce] invalid type sobject type ApexClass is not supported

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.

Best Answer

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.

Related Topic