Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Is there an API method to return what edition current customer is using?

share|improve this question
3  
can you expand on why you want to determine this? typically there are better ways to control things than the edition in use. –  superfell Aug 9 '12 at 6:02

2 Answers 2

up vote 19 down vote accepted

You can query the OrganizationType from the Organization object.

select OrganizationType from Organization

Possible values are "Developer Edition", "Team Edition" (Group), "Professional Edition", "Enterprise Edition" and "Unlimited Edition".

I've also heard rumors of "Base Edition" which is the Performance Edition.

share|improve this answer
4  
Note that this requires the "View All Data" perm to run, or must be run in apex declared as without sharing! –  ca_peterson Aug 8 '12 at 0:58
    
@Daniel, could you add in what the possible options for OrganizationType are? –  Benj Aug 8 '12 at 11:58
    
I can confirm (from SOQLXplorer) that another is "Developer Edition". –  metadaddy Aug 8 '12 at 15:57
1  
If you're using databasedotcom gem, then you can do something like this: client.materialize('Organization').first.OrganizationType –  antonlitvinenko Aug 8 '12 at 17:06
    
Note that when in a Group Edition org, the actual returned value is "Team Edition", not "Group Edition". I have edited the post to reflect this. The API docs for the Organization object do not list out all possible values, so I'm curious, Daniel, where you got your list of possible values. –  zachelrath Jan 14 '13 at 15:31

Use below class to determine the instance and edition of salesforce.

public class whereAmI{

// First method will give us the edition as a string 

public Static String getEdition(){

    // Organization object FTW!
    Organization[] org = new Organization[]{};
    org = [select Id, OrganizationType from Organization limit 1];

    // Check to make sure we have a result
    if(org.size()==1)
        return org[0].OrganizationType;
    else
        return '[still lost...]';
}


// Next method tells us if we're in a sandbox

public Static Boolean isSandbox(){

    String host = URL.getSalesforceBaseUrl().getHost();
    String server = host.substring(0,host.indexOf('.'));

    // It's easiest to check for 'my domain' sandboxes first 
    // even though that will be rare
    if(server.contains('--'))
        return true;

    // tapp0 is a unique "non-cs" server so we check it now
    if(server == 'tapp0')
        return true;

    // If server is 'cs' followed by a number it's a sandbox
    if(server.length()>2){
        if(server.substring(0,2)=='cs'){
            try{
                Integer.valueOf(server.substring(2,server.length()));
            }
            catch(exception e){
                //started with cs, but not followed by a number
                return false;
            }

            //cs followed by a number, that's a hit
            return true;
        }
    }

    // If we made it here it's a production box
    return false;
  }
}

Courtesy : http://www.michaelforce.org/recipeView?id=a0Ga000000Ekp65EAB

share|improve this answer
    
so not all sandboxes start with cs? –  Phil B Oct 30 '13 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.