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
dinesh angaridinesh angari 

Existing picklist values are deactivating while updating new picklist values using Metadata API

Hi All,

I am using Metadata API to update picklist value.
Using SOAP UI to use metadata WSDL, Below is my request to update picklist values. When I am running below request it's creating new picklist values but deactivating existing picklist values...

Please help me what I am missing in below request or Is there any way to insert new values in piclist.


<soapenv:Envelope 
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:met="http://soap.sforce.com/2006/04/metadata" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      <met:AllOrNoneHeader>
      </met:AllOrNoneHeader>
      <met:CallOptions>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>XXXXXXXXXXXXXXXXXXXX</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:updateMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
         <!--Zero or more repetitions:-->
         <met:metadata xsi:type = "CustomField">
        <fullName>Account.salaryDay_c__c</fullName>
        <externalId>false</externalId>
        <label>payday</label>
        <required>false</required>
        <trackTrending>true</trackTrending>
        <type>Picklist</type>
        <valueSet>
            <restricted>false</restricted>
            <valueSetDefinition>
                <sorted>false</sorted>
                <value>
                    <fullName>varun3</fullName>
                    <label>varun3</label>
                </value>
            </valueSetDefinition>
        </valueSet>
         </met:metadata>
      </met:updateMetadata>
   </soapenv:Body>
</soapenv:Envelope>

Thanks in Advance..................
NagendraNagendra (Salesforce Developers) 
Hi dinesh,

Sorry for this issue you are encountering.

If I understand your requirement correctly, Suppose there are three picklist values "a", "b", and "c". With the mentioned values there are records in that object. and you want to replace "a" with "x" , "b" with "y" and "c" with "z". 

You cannot replace existing values with new ones with the metadata API. If you migrate the picklist field with values X, Y and, Z then the existing picklist values A, B and, C get deactivated in the configuration. There will be no change to the data records using those values - you will simply be unable to select A or B or C henceforth in the Page Layouts.

Depending on the number of picklist values you are replacing, the options as I see it are: 1) doing it manually using Salesforce UI's replace function 2) running SOQL update statements to update field = X where field = A 3) creating a new field with appropriate values and deprecating this field.

There might be more obvious but I don't see an easy way out. 

Thanks,
Nagendra
dinesh angaridinesh angari
Hi Nagendra,

Thanks for your reply

Actually what I am trying here is 

1)Manually I created a Picklist field from the front end
2)In that picklist, I want to insert values using metadata API

For Example, I created Picklist field Student Name

In that picklist field(Student Name) I want to insert values using metadata API like (Dinesh,Mahesh,Rajesh)

To do above thing you have any sample SOAP Request, If you have any please send me.


Thanks Again................