Skip to main content
added 143 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

There are some clever workaroundsclever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

There are some clever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

There are some clever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

added 371 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

Unfortunately, picklist + record type information has very uneven coverage across Salesforce APIs.

You can retrieve all picklist values without record type information using either Apex or the Tooling API (a single query, in the latter case). 

You can retrieve picklist values with record type information, for a single record type at a time, using the UI API, with one callout for each field or one for all fields on the object at once. You

You can get all of thisthe information about record types and dependencies by parsing the XML returned fromperforming a retrieve using the Metadata API that includes the appropriate object and field entries.

You could write quite a bit of code to parse out and correlate all of that information from the object's XML source (or the return values via your favorite SOAP client/library), the details of which are going to be beyond the scope of just one answer.

You can retrieve all picklist values without record type information using either Apex or the Tooling API. You can retrieve picklist values with record type information, for a single record type at a time, using the UI API. You can get all of this information by parsing the XML returned from the Metadata API.

You could write quite a bit of code to parse out and correlate all of that information from the object's XML source, the details of which are going to be beyond the scope of just one answer.

Unfortunately, picklist + record type information has very uneven coverage across Salesforce APIs.

You can retrieve all picklist values without record type information using either Apex or the Tooling API (a single query, in the latter case). 

You can retrieve picklist values with record type information, for a single record type at a time, using the UI API, with one callout for each field or one for all fields on the object at once.

You can get all of the information about record types and dependencies by performing a retrieve using the Metadata API that includes the appropriate object and field entries.

You could write quite a bit of code to parse out and correlate all of that information from the object's XML source (or the return values via your favorite SOAP client/library), the details of which are going to be beyond the scope of just one answer.

added 4 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166

You can retrieve all picklist values without record type information using either Apex or the Tooling API. You can retrieve picklist values with record type information, for a single record type at a time, using the UI API. You can get all of this information by parsing the XML returned from the Metadata API.

There are some clever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

Metadata API

The Metadata API is a big topic, so this will only be a quick note. When you pull down an object's metadata, you'll get back XML that includes <recordTypes> elements, which contain <picklistValues> elements:

<recordTypes>
    <fullName>Test</fullName>
    <active>true</active>
    <businessProcess>Test</businessProcess>
    <description>Test.</description>
    <label>Test</label>
    <picklistValues>
        <picklist>Changes__c</picklist>
        <values>
            <fullName>Approved</fullName>
            <default>false</default>
        </values>
        <values>
            <fullName>Requested</fullName>
            <default>false</default>
        </values>
       ... and so on...

And you'll also get <fields> entries for the object:

<fields>
    <fullName>Changes__c</fullName>
    <externalId>false</externalId>
    <label>Changes</label>
    <picklist>
        <picklistValues>
            <fullName>Approved</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Requested</fullName>
            <default>false</default>
        </picklistValues>
        ... and so on...

You could write quite a bit of code to parse out and correlate all of that information from the object's XML source, the details of which are going to be beyond the scope of just one answer.

You can retrieve all picklist values without record type information using either Apex or the Tooling API. You can retrieve picklist values with record type information, for a single record type at a time, using the UI API.

There are some clever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

You can retrieve all picklist values without record type information using either Apex or the Tooling API. You can retrieve picklist values with record type information, for a single record type at a time, using the UI API. You can get all of this information by parsing the XML returned from the Metadata API.

There are some clever workarounds people have developed over the years for getting record type dependency information in Apex, but none of them are supported.

Metadata API

The Metadata API is a big topic, so this will only be a quick note. When you pull down an object's metadata, you'll get back XML that includes <recordTypes> elements, which contain <picklistValues> elements:

<recordTypes>
    <fullName>Test</fullName>
    <active>true</active>
    <businessProcess>Test</businessProcess>
    <description>Test.</description>
    <label>Test</label>
    <picklistValues>
        <picklist>Changes__c</picklist>
        <values>
            <fullName>Approved</fullName>
            <default>false</default>
        </values>
        <values>
            <fullName>Requested</fullName>
            <default>false</default>
        </values>
       ... and so on...

And you'll also get <fields> entries for the object:

<fields>
    <fullName>Changes__c</fullName>
    <externalId>false</externalId>
    <label>Changes</label>
    <picklist>
        <picklistValues>
            <fullName>Approved</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Requested</fullName>
            <default>false</default>
        </picklistValues>
        ... and so on...

You could write quite a bit of code to parse out and correlate all of that information from the object's XML source, the details of which are going to be beyond the scope of just one answer.

added 4 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166
Loading
added 1870 characters in body
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166
Loading
Source Link
David Reed
  • 93.7k
  • 14
  • 90
  • 166
Loading