2

Is it possible to manipulate Picklist's Field Dependencies with Metadata API? If so, is there any reference or example out there?

3

You should be able to, but you got to be careful to construct the xml to match what Salesforce expects. The field dependency and values dependency is stored in the object metadata file. For ex., it is stored in opportunity.object for Opportunity. You can manipulate the data and deploy it back.

Here is an example of configuration in UI:

Field dependency configuration in UI

And how it is represented in Metadata:

Parent Picklist Metadata

    <fields>
    <fullName>Parent_Picklist__c</fullName>
    <externalId>false</externalId>
    <label>Parent Picklist</label>
    <picklist>
        <picklistValues>
            <fullName>Foo</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Bar</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Tom</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Jerry</fullName>
            <default>false</default>
        </picklistValues>
        <sorted>false</sorted>
    </picklist>
    <trackFeedHistory>false</trackFeedHistory>
    <trackTrending>false</trackTrending>
    <type>Picklist</type>
</fields>

Child Picklist Metadata

    <fields>
    <fullName>Child_Picklist__c</fullName>
    <externalId>false</externalId>
    <label>Child Picklist</label>
    <picklist>
        <controllingField>Parent_Picklist__c</controllingField>
        <picklistValues>
            <fullName>Bob</fullName>
            <controllingFieldValues>Foo</controllingFieldValues>
            <controllingFieldValues>Jerry</controllingFieldValues>
            <controllingFieldValues>Tom</controllingFieldValues>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Alias</fullName>
            <controllingFieldValues>Bar</controllingFieldValues>
            <controllingFieldValues>Foo</controllingFieldValues>
            <controllingFieldValues>Jerry</controllingFieldValues>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Fred</fullName>
            <controllingFieldValues>Bar</controllingFieldValues>
            <controllingFieldValues>Foo</controllingFieldValues>
            <controllingFieldValues>Tom</controllingFieldValues>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Velma</fullName>
            <controllingFieldValues>Bar</controllingFieldValues>
            <controllingFieldValues>Jerry</controllingFieldValues>
            <controllingFieldValues>Tom</controllingFieldValues>
            <default>false</default>
        </picklistValues>
        <sorted>false</sorted>
    </picklist>
    <trackFeedHistory>false</trackFeedHistory>
    <trackTrending>false</trackTrending>
    <type>Picklist</type>
</fields>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.