[SalesForce] How to update picklist using REST API

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?

Best Answer

As the other answer says, you can do this via the Tooling API if you want to use a REST call. You can find the details on their answer. The other option is to use 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 the latest update on that idea indicates that as of October 2019 they are not planning on updating that API in the near future.

Related Topic