5

I want to find a way how can I check if a type of object, has any record types specified or not.

I tried, with the describe methods, by acquiring a List, according to the SObjectType, but this doesn't help me, because, even for those objects that I have'nt specified any record types, it returns at least a record type "Master"(which I guess should some internal default value specified by SFDC).

Thank you in advance guys! Endrit.

1 Answer 1

7

You can query the RecordType object to find out the record types that way.

List<RecordType> rts = [select Id 
                       from RecordType 
                       where SObjectType = :MyObject__c.SObjectType
                       ];
if (rts.size() > 0) {
    // MyObject__c has record types
}
1
  • 1
    Thank you! This way is easier to determine if an object has record types or not. Commented Jun 9, 2015 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .