You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Get Picklist Entries Based on the Record Type


In general, Apex help to get all the picklist field values regardless of record type of on sObject, but the values can be retrieved using the schema class.

The below snippet is used to retrieve all the picklist values from the sObject.

Alternatively, the following two ways can read the picklist values based on the record type of the sObject.

  1. sforce.connection.describeLayout
  1. MetadataService

sforce.connection.describeLayout 

The describeLayout() call returns the top-level record type information passed-in sObjectType through the DescribeLayoutResult. Each DescribeLayout is referenced by its unique layout ID.

var result = sforce.connection.describeLayout(<object Name>);

If sObject has record type, recordTypeSelectorRequired displays as ‘true’. Otherwise, it will be false.

MetadataService 

The MetadataService offers the browser based user interface for the Force.com applications. It allows the users to create, update, delete and retrieve records, including the customization information and its processing also.

Use the below link to proceed the installation process.

https://github.com/financialforcedev/apex-mdapi

Sample code: