Posts

Showing posts from March, 2026

Fetch record type-specific picklist values directly in Apex

In Spring ’26, you can fetch record type-specific picklist values directly in Apex using the new  ConnectApi.RecordUi.getPicklistValuesByRecordType(objectApiName, recordTypeId)  method. This eliminates the need for complex, manual UI API callouts, providing cleaner code to get all picklist fields, dependent picklists, and default values for a given record type.   Example - Id accrecordTypeId = Schema.SobjectType.Account.getRecordTypeInfosByDeveloperName().get('Test_RT').getRecordTypeId(); ConnectApi.PicklistvaluesCollection result =  ConnectApi.RecordUi.getPicklistValuesByRecordType('Account', accrecordTypeId); for(ConnectApi.PicklistValue pv: result.PicklistFieldValues.get('Rating').values){     system.debug(pv.label + ' '+pv.value); }