4

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.

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. – Endrit Sino Jun 9 '15 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.