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
MellowRenMellowRen 

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

Hi

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?

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

http://www.jonathanbroquist.com/retrieving-sobject-recordtypeid-dynamically-with-salesforce/