+ Start a Discussion
CliffordClifford 

Retrieve the picklist value "id" using the API

Is there a way to get the "id" of a picklist value through the API?  We are using picklist values in an external system and when a picklist value is updated, would like to "push" this updated value to the external system via the id.

 

Looking at the edit page, it seems it may be possible to get at the id, but I do not see this available through the API.  Is there a way to get this id value?

 

Examples through the edit screen:
picklist_masteredit.jsp?id=01J400000088LJZ
picklist_masteredit.jsp?id=01J400000088LJa

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
aalbertaalbert

I am still a little unclear on why you need the ID (which as you found out, is not exposed...which is on purpose). A picklist is keyed off its text value. So if you want to add a new picklist value through the metadata api, you provide a text field. NOTE - you can not edit or delete picklist values through the metadata api currently.

 

 

All Answers

aalbertaalbert

Are you looking to get the picklist value selected for a given record? Or are you looking for the list of possible Picklist values as configured for a given field? The reason I ask is because you access those values differently thorugh the API.

 

If you just want the selected value for a given record, the value is set on the field itself.

But if you want to get all the possible picklist values, then you need to use the Describe API

 

 

CliffordClifford
Thanks for the reply and I should have been more clear on what I am looking to do...I want to get back all values in a picklist for a particular record type.  I am able to do this, however I seem to only have access to the text value, but not the underlying id's.   Having the list of id's and values is needed as we need the id's to perform updates when picklist values change (update value...where id = id)
Message Edited by Clifford on 02-09-2009 05:33 PM
aalbertaalbert

I am still a little unclear on why you need the ID (which as you found out, is not exposed...which is on purpose). A picklist is keyed off its text value. So if you want to add a new picklist value through the metadata api, you provide a text field. NOTE - you can not edit or delete picklist values through the metadata api currently.

 

 

This was selected as the best answer
CliffordClifford

We are trying to do a one way sync of data from SFDC to an external system.  Initially we would have the same values in SFDC and the external sys...and say one value in the picklist is "Shoe" and it gets updated to "Shoes". In the external system we are using relational tables, so if we have an order table, with order items, we would have the id value for "Shoe" in the related tables.  Now, when the new value "Shoes" comes over from SFDC, we need a key or id (unless there is an alternative) to know that "Shoe" in our system needs to be updated to "Shoes".

 

Sounds like, since the id is not avail through the API, nor can we edit picklist values through the API, that we can not implement a fully automated solution as outlined above....

aalbertaalbert

Well, at the metadata layer (ie the configuration of the picklist values), you won't get the picklist value IDs amongst some of the other limitations.

 

But if you are sync'ing the data (ie the order, order line items), you will get the record IDs for those records and would use the standard Web Services API (ie query, insert, update, delete) and not the metadata API. 

 

 

JasonHillPDXJasonHillPDX

I'm wondering if anyone else has other thoughts on this?

 

I need to replicate a pick list in another system and without knowing what a picklist item's ID is, I can't figure out how to handle edits to the picklist item.

 

I understand that in the metadata layer the ID is not exposed. Is there another layer that I could query where it would be exposed?

 

Or, is there an audit log for picklists somewhere that I could monitor for edits?

 

Any other ideas?

Apex LearnerApex Learner

hi i have woring on METADATA Api 

 

and i have successfully create soap envelope to add new picklist value in picklist field

via

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
   <soapenv:Header>
      <met:CallOptions>
         <met:client>---</met:client>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>---</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <update xmlns="http://soap.sforce.com/2006/04/metadata">
     <!--Zero or more repetitions:-->
      <UpdateMetadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="customfield">
		    <currentName>lead.number__c</currentName>
		                
		      <metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CustomField">
		      <!--Optional:-->
		       <fullName>lead.number__c</fullName>
		       <label>number</label>
		    		<picklist>
		              <picklistValues>
		         			<fullName>new</fullName>
		              </picklistValues>
		         		 <sorted>false</sorted>
		  		</picklist>
		         <type>Picklist</type>
		    </metadata>
         </UpdateMetadata>
       </update>
   </soapenv:Body>
</soapenv:Envelope>

 Now issues I am facing , is

Is there any way to update / edit any particular picklist value ???

 

e.g , Object : Lead , field : number__c, type : picklist , picklist values : new , old 

 

any way i can edit "new " to "new_value" via meta data API .

 

Thanks to soap and metadata api developers in advance 

rrogersiiirrogersiii

Jason, Clifford - were you ever able to get an answer to this question?  I ask, because I'm faced wtih the same challenge you are. 

 

We are doing a one-way data sync from salesforce to our relational system, and I need some way to understand if the values "shoe" and "shoes" actually represent the same picklist item (if/when someone has gone in to SalesForce and edited "shoe" to become "shoes").  

 

Without an ID, "shoe" and "shoes" will look like two separate picklist items ... which will turn into two separate rows in our relational system ... which is not what we want.

Glenn WeinsteinGlenn Weinstein
Good question, which this thread doesn't answer.  I'm still wondering myself.  You stated it perfectly - there are scenarios (e.g. external integrations) where we need to know the ID of the selected picklist value, not the text string, so that other systems can stay in sync with metadata-level changes to the SFDC picklist values (e.g. if a SFDC admin changes "Shoe" to "Shoes" in the picklist definition).
Glenn WeinsteinGlenn Weinstein
Oh - I did find this idea, to expose the ID - https://success.salesforce.com/ideaView?id=08730000000bBlSAAU