function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CliffordClifford 

Retrieve or filter picklist based on RecordType through the API

I was using the below code to retrieve picklist values through the API.  We have now introduced RecordTypes and we need to limit the picklist values we retrieve (or filter out) to those for a particular RecordType.
 
Does anyone have sample code on how to do this?  We will know the RecordTypeId, just not sure how to use that to filter the picklist.  Should this be done with the describeLayout()?
 
//Following gets all picklist vlaues...does not filter based on RecordType
DescribeSObjectResult result = _binding.describeSObject("MyObject__c");
int numberOfPicklistItems = 0;
int fieldIndexOfPicklist = 0;
for (int i = 0; i < result.fields.Length; i++)
{
 if (result.fields[i].name == ConfigurationData.FieldName)
 {
  numberOfPicklistItems = result.fields[i].picklistValues.Length;
  fieldIndexOfPicklist = i;
  break;
 }
}
for (int i = 0; i < numberOfPicklistItems; i++)
{
 ActivityList.Add(new ActivityListItem()
 {
  Value = result.fields[fieldIndexOfPicklist].picklistValues[i].value,
  Label = result.fields[fieldIndexOfPicklist].picklistValues[i].label
 });
}
 
 
Thanks...