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

Adding new picklist values using Apex

Is there any way to insert new picklist values using Apex for a Custom Object?
I don't think so, but the new Developer Guide has an example to use Visualforce components and a related object to replicate the functionality of picklists.  This example includes a way to add a new value for the picklist.  The example recreates dependent picklists, but you can use the same approach for regular picklists.

Hope this helps.  You can download the Developer Guide as part of the Developer library here -

Message Edited by RickyG on 11-14-2008 10:36 AM

Message Edited by RickyG on 11-14-2008 10:37 AM

Message Edited by RickyG on 11-14-2008 10:39 AM

Hi Rick,

Thanks for the info. But I was looking to insert picklist values to the object itself  not through visual force page.




A few more bits of information on this:


You can create custom picklists using Visualforce and Apex, by creating an Visualforce Controller Extension. SeeChapter 12, page 371, of the Developer Guide, for a detailed example of a picklist, populated with values via Apex.


I believe this could even allow you to extend your # of picklist values beyond the default of 250 items (though i haven't tried it.)