I'm passing the object name based on the Id of an object and I'm not sure how to convert from String to SObject so if I have hard code the name of the object it works fine.

Schema.DescribeSObjectResult objSchema = Employee__c.sObjectType.getDescribe();


Initial term of field expression must be concrete sObject: String

Id myid = 'a0Ci000000vd7xA';     
String objectName = myid.getSobjectType().getDescribe().getName();

Schema.DescribeSObjectResult objSchema = objectName.sObjectType.getDescribe();
Map<String, Schema.SObjectField> fieldMap = objSchema.fields.getMap();
for (String fieldName : fieldMap.keySet()){
    SObjectField sfield = fieldMap.get(fieldName);
    schema.describefieldresult dfield = sfield.getDescribe();
    if (null != dfield.getInlineHelpText()) {
        //System.debug(dfield.getName() + ':' + dfield.getInlineHelpText());
  • 1
    Would not myid.getSobjectType() return the same Schema.DescribeSObjectResult object you are expecting in line 3? Mar 22, 2017 at 16:25

2 Answers 2


One (particularly inefficient) method is to use Schema.getGlobalDescribe:

DescribeSObjectResult objSchema = Schema.getGlobalDescribe().get(objectName)

I would personally use getSObjectType on an Id, which skips a very expensive describe call:

DescribeSObjectResult objSchema = myid.getSObjectType().getDescribe();

Or, you could even use the key prefix if you wanted to keep it as a string:

DescribeSObjectResult objSchema = Id.valueOf(objPrefix+'0'.repeat(12))
  • sfdcfox,May I ask why you are repeating 0's 12 times here on your last line of code? key prefix is 3 digits but why 12 repetition of 0's?
    – SF Learner
    Mar 22, 2017 at 22:19
  • @ShaliniMendu Because an ID is 15 or 18 characters long. So, for example, if you use '001' as the prefix, you would get '001000000000000', which Apex would interpret as an Account Id. The remaining 12 characters (mostly) don't matter as far as Id.getSObjectType is concerned, so you can use 0 values.
    – sfdcfox
    Mar 22, 2017 at 22:36
  • So, its not the exact Id that you are trying to create here, it just is to indicate the type of the object(using keyprefix). I thought the system would complain of Invalid Id or something of that sort if it doesn't match with an exact ID.. good to know this little tip!Thanks for your clarification.
    – SF Learner
    Mar 22, 2017 at 22:42

You can manipulate the DescribeSObjectResult however you wish if you just omit your getName() call:

DescribeSObjectResult describe = myId.getSObjectType().getDescribe();
for (SObjectField field : describe.fields.getMap().values)
    if(field.getDescribe().getInlineHelpText() != null))

You don't even need to cache the Id:

DescribeSObjectResult describe = Id.valueOf('a0Ci000000vd7xA').getSObjectType().getDescribe();
  • getting error Invalid type DescribeSObject
    – Nick
    Mar 22, 2017 at 17:41
  • @NickKahn Just a typo.
    – Adrian Larson
    Mar 22, 2017 at 17:52

You must log in to answer this question.

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