What I have done : Installed repository from GIT HUB In my Personal org https://githubsfdeploy.herokuapp.com/app/githubdeploy/financialforcedev/apex-mdapi

Created a custom controller and method : Inside method getting

Variable does not exist: picklist

in this line


Apex method:

private void addPicklistValue(MetadataService.CustomField customField, string picklistValue) {

    MetadataService.MetadataPort service = createService();

    metadataservice.PicklistValue newPicklistvalue = new metadataservice.PicklistValue();
    newPicklistvalue.fullName= picklistValue;
    newPicklistvalue.default_x = false;


    List<MetadataService.SaveResult> results = service.updateMetadata(new List<MetadataService.Metadata> {customField });


Why do I get this error? How can I fix it?

1 Answer 1


You are trying to access a property of the CustomField Metadata API entity, picklist, that is deprecated and unavailable in current API versions. From the linked Metadata API reference for CustomField:

picklist: (Deprecated. Use this field in API version 37.0 and earlier only. In later versions, use valueSet instead.)

For this reason, you will not find it in current versions of apex-mdapi. Presumably you're working from sample code or examples that are out of date.

As is common when working with the Metadata API, you'll have to do some legwork to understand the complex data structures that are in use. The ValueSet type and its nested ValueSetValuesDefinition type are documented in the Metadata Field Types documentation.

In the apex-mdapi library, you'll find the definition of the ValueSet class inside MetadataService.cls.

That's what you'll need to use to make your updates.

You must log in to answer this question.

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