How to retrieve the Record Type which are accessible by user’s Profile only?

How to retrieve the Record Type which are accessible by user’s Profile only?

isAvailable() from RecordTypeInfo object/entity can be used to retrieve the Record Type which are accessible by user’s Profile only.

Using the following sample Apex Code, we should be able to find out the Account object/entity Record Types that are available to the running user.

Sample Code:

for ( 
    RecordTypeInfo recTypInfo : 
    Account.SObjectType.getDescribe().getRecordTypeInfos() 
) {
    
    if ( recTypInfo.isAvailable() ) {
        
        System.debug(
            'Record Type Id is ' +
            recTypInfo.getRecordTypeId()
        );
        System.debug(
            'Record Type Name is ' +
            recTypInfo.getName()
        );
        
    }
    
}

Output:

Leave a Reply