+ Start a Discussion

How can I determine a generic SObject List’s RecordType Names?


I am hopeless with the whole Schema and getDescribe thing. Is this possible? Can anyone point me in the right direction?

I am trying to build a generic method that if passed a List of SObject (type unknown when passed) will return (ideally) a Map of the Record Type Names.

public Map<ID, String> getRecordTypeNames(List<SObject> theSObjects) {

Salesforce documentation suggests that a getDescribe is the best practice method but at this point I’d be happy enough with an SOQL based solution as well. My hangup is that in both cases I need to know what type of object (Account, Opportunity, etc) each record is before I can get the record type but to do that I will end up with a non-bulkified solution (I think).

I am really hoping I am missing something obvious here. Google and forum searching appear to be failing me though :-(

Any advice?

Hi MellowRen, The below post explains best approaches of retrieving record type id's dynamically. See if that helps