Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to see if an object exists using the following code:

public with sharing class GenericUtils {
     public static Boolean doesObjectExist(String objectName) {
          Map<String, Schema.SObjectType> result = Schema.getGlobalDescribe();
          return result.containsKey(objectName);

When I run the following in the Developer console, it returns false.


However, when I run this in the Developer console, it returns true.

Map<String, Schema.SObjectType> result = Schema.getGlobalDescribe();

I have tried making the GenericUtils class both with and without sharing with no change in outcome. When I inspect the keySet of the map they return two different sets of data. Is there something that I am missing, or is this expected behavior?

share|improve this question
up vote 4 down vote accepted

What is the API version of the GenericUtils class? If it's API v24.0 or lower then the LiveChatTranscript sObject type isn't valid and won't be returned by calls to Schema.getGlobalDescribe().

The webservice API docs contain the minimum API version for each sObject type:

share|improve this answer
That was it. The GenericUtils class had an older API version. Upping the version >24 fixed it! – Patrick Connelly Dec 14 '12 at 14:10

This post suggests that you need to add access to the GenericUtils Apex class to the profile of your running user.

I'd give that a whirl. Also, I suspect that perhaps with / without sharing may behave differently, so try without sharing and see if that might also fix your issue.

share|improve this answer
The user is a System Admin and has access to the Apex Class. And it behaves the same regardless on sharing settings :/ – Patrick Connelly Dec 13 '12 at 20:27

Your Answer


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.