You need to sign in to do that
Don't have an account?
nimbusproject
How do you Dynamically get Field types on an sObject type
Is there any way of getting the field types dynamically by just having a String containing the name of an sObject type? (such as Contact or Account)
How would you do the following dynamically rather than put in the object type statically (in this case Contact)
Contact.sObjectType.getDescribe().fields.getMap();
So I pretty much need to do the following
<sObject type HERE>.getDescribe().fields.getMap();
Only having a string of the object type name Contact.
You need to use the getGlobalDescribe() method to acquire the respective token:
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType ctype = gd.get('contact'); Map<String, Schema.SobjectField> fmap = ctype.getDescribe().fields.getMap();
All Answers
You need to use the getGlobalDescribe() method to acquire the respective token:
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType ctype = gd.get('contact'); Map<String, Schema.SobjectField> fmap = ctype.getDescribe().fields.getMap();