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
RaghavenderRaghavender 

Deploying Changes to Picklist values using MetaData API

HI, 

 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

 

Ispita_NavatarIspita_Navatar

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(); 

unsubmitted.setFullName("Unsubmitted"); 

PicklistValue submitted = new PicklistValue(); 

submitted.setFullName("Submitted"); 

PicklistValue approved = new PicklistValue(); 

approved.setFullName("Approved"); 

PicklistValue rejected = new PicklistValue(); 

rejected.setFullName("Rejected"); 

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

CustomField expenseStatusField = new CustomField(); 

expenseStatusField.setFullName(      "ExpenseReport__c.ExpenseStatus__c"); 

expenseStatusField.setLabel("Expense Report Status"); 

expenseStatusField.setType(FieldType.Picklist); 

expenseStatusField.setPicklist(expenseStatus); 

try

{   

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

}

catch (ConnectionException ce)

{   

ce.printStackTrace(); 

}

}

 

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  ??

 

 

ranjeet.ax1557ranjeet.ax1557

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

      $customObject->setDescription("A description");
      $customObject->setEnableActivities(true);
      $customObject->setEnableDivisions(true);
      $customObject->setEnableHistory(true);
      $customObject->setEnableReports(true);
      $customObject->setHousehold(false);
      $customObject->setLabel("My Custom Obj from PHP");

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

     $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';


     $customField->setPicklist($object);
     $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>

</select>


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>

.....