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

Deploying Changes to Picklist values using MetaData API


 i was trying to deploy the cahnges to picklist values for one of the custom object, the exisitng picklist valued not included int he .object file are also retained.

IS there a way we can remove those unused values in the picklists.


Thanks in Advance



Hi Raghavender,

Are you trying to create the picklist value through code as below:-


public void setPicklistValues()

// Create a picklist 

Picklist expenseStatus = new Picklist(); 

PicklistValue unsubmitted = new PicklistValue(); 


PicklistValue submitted = new PicklistValue(); 


PicklistValue approved = new PicklistValue(); 


PicklistValue rejected = new PicklistValue(); 


expenseStatus.setPicklistValues(new PicklistValue[]      {unsubmitted, submitted, approved, rejected});   

CustomField expenseStatusField = new CustomField(); 

expenseStatusField.setFullName(      "ExpenseReport__c.ExpenseStatus__c"); 

expenseStatusField.setLabel("Expense Report Status"); 





AsyncResult[] ars =    metadataConnection.create(new Metadata[] {expenseStatusField}); 


catch (ConnectionException ce)






If yes is it still creating the unused values ? Do let me know.



Rahul SharmaRahul Sharma

You can edit the metedata of the object in eclipse and copy paste the values from that picklist field from source org to destination org.

Just save the metadata, by doing that you will be able to save/change the values in picklist field.

But, Take a backup the metadata(xml) of that object before saving in case to avoid any problem.

Apex LearnerApex Learner

is there any way to edit picklist value through metadat API . 

I am current testing meta data API via SOAP ui and till now I am able to add picklist values .

but can not edit any perticuler picklist value 


eg . object : lead 

       field : number__c

  type : picklist


values : 1 , 2


any methode i cn edit 1 to 11  ??




$customObject = new SforceCustomObject();
      $customObject->fullName = 'CustomObjFromPHP__c';
      $customObject->deploymentStatus = DEPLOYMENT_STATUS_DEPLOYED;

      $customObject->setDescription("A description");
      $customObject->setLabel("My Custom Obj from PHP");

      $customField = new SforceCustomField();
      $customField->setDescription('Description picklist for mailchimp Listing');
      $customField->setLabel('My Picklist for list');

     $object=new stdClass();
     $object->sorted= false;
     $object->picklistValues    = array();
     $object->picklistValues[0] = new stdClass();
     $object->picklistValues[0]->default    = false;
     $object->picklistValues[0]->fullName   = 'Test Source';

     $customObject->nameField = $customField;

      $customObject->pluralLabel = 'My Custom Objs from PHP';
      $customObject->sharingModel = SHARING_MODEL_READWRITE;

    echo "<pre>";  print_r($myMetadataConnection->create($customField));echo "</pre>";

I created the dropdown. below...

<select tabindex="14" name="00Nd0000005ak08" id="00Nd0000005ak08"><option value="">--None--</option>

<option value="Test Source">Test Source</option>


I want to  set option value =' any interger number' not same as label....
for eq.
<option value="1">Test Source</option>

<option value="2">Test  new </option>
<option value="integer no ">my label</option>