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. 

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
  2. 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
getting picklist entries

Sample code: 

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Session Based Permission Sets

A Permission Set is a collection of settings and permissions that give access to users to various tools and functions. The settings and permissions in Permission Sets are additionally found in profiles, but permission sets broaden users’ functional access without altering their profiles.

Read Article »

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.