You need to sign in to do that
Don't have an account?
Dynamically get fields for an SObject - no hardcoding
Hi ..... It states in Salesforce Apex docs that I can get fields for a particular SObject (standard or custom) in the following way:
Map<String, Schema.SObjectField> M = Schema.SObjectType.Custom__c.fields.getMap();
But this requires hardcoding. as I need to hardcode the API name of the SObject : Schema.SObjectType.<CUSTOM__C> -- hardcoding.
Isnt there any way to access all fields on an SObject dynamically w/o hardcoding? I am getting a list of all SObjects in my org by calling Schema.getGlobalDescribe(), but this leaves me with API names of individual SObjects. There is no way to get all those SObject's field info dynamically. Am I missing something or it is just not possible?
i.e. I would want to have something like:
List <Schema.SObjectField> fieldList = Schema.SObjectType.get(SObject_API_Name).fields;
Please guide.
Regards
S_2013
If you look at how it works is that it need to know for which object it should return list of fields. So it makes absolutely sense.
If you could share your requirement, may be I will be able to give a thought.
Happy to help you!