RecordTypeInfo Class

Contains methods for accessing record type information for an sObject with associated record types.

Namespace

Schema

Usage

A RecordTypeInfo object is returned from the sObject describe result using the getRecordTypeInfos method. For example:

Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();

In addition to the getRecordTypeInfos method, you can use the getRecordTypeInfosById and the getRecordTypeInfosByName methods. These methods return maps that associate RecordTypeInfo with record IDs and record labels, respectively.

Example

The following example assumes at least one record type has been created for the Account object:

RecordType rt = [SELECT Id,Name FROM RecordType WHERE SobjectType='Account' LIMIT 1];
Schema.DescribeSObjectResult d = Schema.SObjectType.Account; 
Map<Id,Schema.RecordTypeInfo> rtMapById = d.getRecordTypeInfosById();
Schema.RecordTypeInfo rtById =  rtMapById.get(rt.id);
Map<String,Schema.RecordTypeInfo> rtMapByName = d.getRecordTypeInfosByName();
Schema.RecordTypeInfo rtByName =  rtMapByName.get(rt.name);
System.assertEquals(rtById,rtByName);

RecordTypeInfo Methods

The following are methods for RecordTypeInfo. All are instance methods.

getDeveloperName()

Returns the developer name for this record type.

Signature

public String getDeveloperName()

Return Value

Type: String

getName()

Returns the UI label of this record type. The label can be translated into any language that Salesforce supports.

Signature

public String getName()

Return Value

Type: String

getRecordTypeId()

Returns the ID of this record type.

Signature

public ID getRecordTypeId()

Return Value

Type: ID

isActive()

Returns true if this record type is active, false otherwise.

Signature

public Boolean isActive()

Return Value

Type: Boolean

isAvailable()

Returns true if this record type is available to the current user, false otherwise. Use this method to display a list of available record types to the user when he or she is creating a new record.

Signature

public Boolean isAvailable()

Return Value

Type: Boolean

isDefaultRecordTypeMapping()

Returns true if this is the default record type for the user, false otherwise.

Signature

public Boolean isDefaultRecordTypeMapping()

Return Value

Type: Boolean

isMaster()

Returns true if this is the master record type and false otherwise. The master record type is the default record type that’s used when a record has no custom record type associated with it.

Signature

public Boolean isMaster()

Return Value

Type: Boolean