I have created two picklist values using metadata api and able to insert the values in the both the picklists, but I have to set the dependency between them, like one is controlling and other would be dependent. I don't want to do it manually.

Here is the code which is working fine to update the picklist values in the picklist fields. But having two issues.

  1. It is setting all the values inactive except the last one though I am setting isActive=TRUE for all the values.
  2. Not found anything to set the controlling and dependent picklist values.

    MetadataService.ValueSet picklistValueSet = new 
    MetadataService.ValueSetValuesDefinition valueDefinition = new 
    List<MetadataService.CustomValue> values = new 
    MetadataService.CustomValue customValue1 = new 
    customValue1.fullName = picklistValueFullname ;  // inserting from csv
    customValue1.isActive = TRUE;
    customValue1.default_x = FALSE;
    customValue1.label = picklistValueLabel; // inserting it from csv
    valueDefinition.value = values;
    valueDefinition.sorted = false;
    picklistValueSet.valueSetDefinition = valueDefinition;
    customField.valueSet = picklistValueSet;
    List<MetadataService.SaveResult> results = service.createMetadata(new 
    MetadataService.Metadata[] { customField });        

1 Answer 1


Check the documentation here on controlling and dependent picklists:


and especially:



It's tricky to set this up programmatically. I suggest setting up a dependent picklist in the Salesforce UI and then studying what that metadata looks like. Good luck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .