In apex code I want to enumerate the legal values for a picklist field. To do this I can just call Account.Foobar__c.getDescribe().getPickListValues()
and I've got a list of Schema.PickListEntry values.
However it's possible to setup multiple record types for a given sObject. For example Account might have "Manufacturer", "Distributor" and "Retailer" record types. In the Salesforce setup it is possible edit (limit) the picklist entries for each field based on record type. So Retailer type accounts might only use a subset of the picklist values for the Foobar field.
So basically I want Account.Foobar__c.getDescribe().getPickListValues('Retailer')
however this is not the syntax. The validFor method looks promising, but it seems like it is only for field dependent picklists - a picklist filtered only by record type returns false for isDependentPicklist
.
Click: Setup > Create> Objects> Section_2_Balance_Sheet_c> Record Types > then click on each of the record types you need to add the picklist value to. On the record type detail page you will find a section called Picklists Available for Editing. From that list locate your picklist field and click Edit. Add the values you need to the right column.
Record types in Salesforce allow you to have different business processes, picklist values, and page layouts to different users based on profile. You might create record types to differentiate your regular sales deals from your professional services engagements, offering different picklist values for each.
For example, for creating account record type is lightning From Setup, click Object Manager and select Account. Select Record Types, click New, and fill in the details. Page layouts control the layout and organization of buttons, fields, Visualforce, custom links, and related lists on object record pages.
Field dependencies are filters that allow us to change the contents of a picklist based on the value of another field. Rather than displaying every value for Region in a single picklist, you can limit the values that are displayed based on a value for another field, like Zone.
I know this is an old post, but maybe the info below will help someone who still needs the answer.
I found here that one can actually get a list of record type specific picklist values by making a describeLayout() call.
Using your example (C#):
DescribeLayoutResult result = binding.describeLayout("Account", new string[] { "01230000000xxXxXXX" } ); PicklistEntry[] values = result.recordTypeMappings[0].picklistsForRecordType[12345].picklistValues;
You can't do it in pure Apex AFAIK, unfortunately. The metadata API does expose it.
Related opinions: http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With