Would anyone have an example on how to update a picklist?

I have a System Custom Field that I want to append add new items to as it comes up.

The details of the field are the following:

  • Field Label: Device Status
  • Field Name: Device_Status
  • API Name: Device_Status__c
  • Object Name: System Data
  • Type: Picklist

How can I append one picklist value using REST API?

  • 1
    By the way, if this is not a Restricted Picklist, you can insert (via the API) any value you wish in the picklist. – sfdcfox May 8 '18 at 15:47
  • Thank you, you are exactly right about this. I unchecked the box "Restrict picklist to the values defined in the value set". After that I was able to send other values. Then when I checked the custom field, the values were listed in two catergories "Values" and "Inactive Values". – Kris May 8 '18 at 22:09

Unfortunately this cannot be done using the REST API. What you need to use instead is the Metadata API which is a SOAP API. This stackexchange post has some example code about updating picklists using the Metadata API. The first link to the Metadata API docs should get you started on how to use it. If you are trying to do this in Apex, there is an apex wrapper for the Metadata API on Github.

There is an idea for implementing the Metadata API in Apex natively here, and it appears that as of April 10, 2018 we are still a year out from getting field updates and picklist values added to the native Apex Metadata API.

  • Thank you, you are right. I was able to find a different way to accomplish this. – Kris May 8 '18 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.