I need to dynamically add and remove values from a custom picklist using APEX code. I want this to be reflected in the picklist meta data e.g. not only appear in record details. How can I do that using my apex logic?

1 Answer 1


This should be doable in APEX with the following:

  1. Take a look at the Apex wrapper to the SFDC Metadata API here: http://andyinthecloud.com/2014/08/14/apex-metadata-api-streamlined-and-simplified-for-summer14/
  2. Code is available here: https://github.com/financialforcedev/apex-mdapi
  3. You need to be at V30+ to use synchronous calls

The metadata api allows manipulation of the SFDC metadata, including updating picklists which is one of the examples in the GIT repo

One caution is that you would be updating PROD metadata without rerunning regression tests so you might break your application inadvertently.

Of course, the user executing the code would need Customize Application privileges.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .