0

I am unable to get the schema of the Lead object using:

Schema.getGlobalDescribe().get('Lead') 

this is returning null.

I did not have any problem while getting the schema of Account or Contact.

In my dev environment I DO got success to get the Lead schema, but no luck on the production environment.

Any advice?

Thanks.

1
  • Can you give some more context? Where are you trying to call this code? What API Version are you using?
    – Adrian Larson
    Commented Oct 18, 2016 at 14:51

1 Answer 1

0

Can you try an see if the "lead" is coming in the debug or not to check?

Schema.SObjectType objType = Schema.getGlobalDescribe().get('Lead');
Map<String,Schema.SObjectType> objMap = Schema.getGlobalDescribe();
for(String str : objMap.keySet()) {
    System.debug(str + ' = '+ objMap.get(str));
}

Post the result from the above code.

4
  • I checked and the user has full administrative rights ("System Administrator"). And I can see that he has the permission for Lead as same as Contact or Account.
    – Talgo
    Commented Oct 18, 2016 at 10:59
  • Permissions issues should not block you from seeing the schema.
    – Adrian Larson
    Commented Oct 18, 2016 at 14:47
  • Also note that Schema.SObjectType.Lead yields exactly the same describe as Schema.getGlobalDescribe().get('Lead').
    – Adrian Larson
    Commented Oct 18, 2016 at 14:49
  • Edited the answer. please try the code to check if the Describe is returning the Lead. Commented Oct 18, 2016 at 15:03

You must log in to answer this question.

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