+ Start a Discussion

Selected record types of Specific profile on Specific Object

I have logged in as System Admin profile, In apex I wrote the code to
retrieve the selected record types of Account object. For example, in
account object I have 10 record types and I have selected only 5 record
types to one profile( X Profile). From the apex code, I want to retrieve
selected record types of Account object for specific profile( X Profile)

This is the code for current user profile record types. Now I want to get
the record types of specific profile. When I pass the profile Id, I want to
get the account object record types of that profile

public without sharing class SelectedRecordTypes {
public static List GetAvailableRecordTypeNamesForSObject( Schema
.SObjectType ObjType, Id profileId ) {
try {
User userId = [Select Id from User where Profile.Id =:profileId];
List names = new List();
List RecordTypes= new List();
List recTypeIds = new List ();
List infos = objType.getDescribe().getRecordTypeInfos();

// If there are 2 or more RecordTypes...
if (infos.size() > 1) {
for (RecordTypeInfo i : infos) {
if (i.isAvailable()
// Ignore the Master Record Type, whose Id always ends with
// We check the Id because Name can change depending on the
user's language.
&& !String.valueOf(i.getRecordTypeId()).endsWith('AAA'))
// Otherwise there's just the Master record type,
// so add it in, since it MUST always be available
else names.add(infos[0].getName());
RecordTypes = [select Id, name from RecordType where Name IN :names];
for (RecordType rec : recordTypes) {
return RecordTypes;
} catch ( Exception recTypeException ) {
system.debug(':::::::::: recTypeException:'+recTypeException);
return null;

Is there any way to retrieve Selected record types of Specific profile on Specific Object?
Hi , 

See the below threads with similar issue,

Finding if which users have a record type available to them using SOQL


how to determine which profiles are assigned to a record type