function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dke01dke01 

Dynamic getDescribe()

There are alot of example of people using the below code
Map<String, Schema.SObjectField> M = Lead.sObjectType.getDescribe().fields.getMap();


What I want to do is instead of Hard Coding the sObject in this Case Lead  pass it as a string paramater

so how would I do something like

 

GetType('MySobject__c').getDescribe().fields.getMap();

 

 

 

dke01dke01

Ok I found another post with the answer

 

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType ctype = gd.get('contact'); Map<String, Schema.SobjectField> fmap = ctype.getDescribe().fields.getMap();

 

 or I could probably just use 
describeSObjects()

 

SamHowleSamHowle
Thanks! This just helped me figure out another similar issue.