I have a two picklists PL1 and PL2. PL1 is controlling picklist and PL2 is dependent picklist.
I want to fetch values of PL1 in Apex depending on recordTypes in Apex method, which I already have using the API endpoint
/ui-api/object-info/{0}/picklist-values/{1}/{2}.
Now I want to fetch the dependent values of PL2 in a map depending on record type. Is there any API endpoint for the same?
I have already read some blogs on fetching dependent picklist values, but none of them implement record types.
Best Answer
According to UI API for Salesforce:
The endpoint:
gives you valid values for record type along with controlling fields and their values.
In the documentation, it gives an example for Country to City dependent picklist for a given recordType. The sample response would look like
Which you can easily parse and create map of dependent picklist values depending on record type
Here for dependent field City__c see the controlling values for countries in controllerValues
Src: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_features_records_dependent_picklist.htm?search_text=dependent