I am implementing an inline VF page where I need to show list of accessbile record types of Opportunities to user. It is also listing Master record type.
Following is the code,
for(RecordTypeInfo info: Opportunity.SObjectType.getDescribe().getRecordTypeInfos()) {
if(info.isAvailable()) {
System.debug('info - '+info);
}
}
The current logged in user has no access to Master record type on profile. When I click on standard New opportunity button on tab I don't see master record type whereas I can see other record types accessible. I have also checked permission sets assigned to logged in user which also does not have access to Master record type.
Best Answer
I just tried mentioned code, and I have the same. Bug probably ? For me it is bug. Add few more lines of code to handle it:
There are two possible scenarios to handle. In case, when there are other available recordtypes except
Master
, result ofinfo.isMaster() && !info.isDefaultRecordTypeMapping()
will betrue
and methodisRecordTypeAvailable
will returnfalse
. That means, that there is not only master availablerecord type
on object and user shouldn't have access tomaster
. In case, when there is onlymaster
recordtype on object method will returntrue
. So there is onlymaster
record type available and it is default, that means that user should have access tomaster
recordtype.