Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Salesforce edition and/or capabilities from Apex/VisualForce

From within an Apex class, how can I detect the Edition (ie, Group, Professional, Enterprise, Unlimited). More specifically, is there an API to retrieve the capabilities (or lack thereof) for the user's edition?

The problem I am trying to solve is that from the Group/Professional edition, users cannot access the custom Web Services in my app, receiving the error LOGIN_OAUTH_API_DISABLED. Is there a way to detect whether this is going to work from within Apex?

like image 914
Vincent Avatar asked Sep 01 '25 10:09

Vincent


2 Answers

You can use the following SOQL to determine the Organization's license type:

SELECT OrganizationType FROM Organization

For Professional it will return "Professional Edition". This is detailed on the Organization object page.

like image 110
Ryan Elkins Avatar answered Sep 04 '25 03:09

Ryan Elkins


Are there any specific capabilities you're looking to discover? There's no way to determine the edition (and this would be mostly a red herring if you could). A lot of differences end up being reflected in the data model, and you can discover that using the describe features.

If you want to check from apex if your web services is enabled/available, then you could use apex callouts to try and make a call to it (and FWIW, the error code is from OAuth, and not from your apex web service)

like image 21
superfell Avatar answered Sep 04 '25 02:09

superfell