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
nelnel 

How to add value to picklist programmatically

In Product object, we have a custom field 'Product Group', it's a picklist.

 

Product data are imported from an external application, and there could be new Product Group added at any time. Our customer requested us to pupulate new Product Group to the picklist during the data import when the value is new.

 

I'm planning to create a trigger to the Product object, and check whehter the Product Group exists in the picklist, if not, add it in. I've read some threads that metadata api might be able to do this job, but i can't find any documentation or sampel code for this, any help is appreciated.

gbu.varungbu.varun

It can not be done through programming. You can create a custom object and insert a new reocord in it. You can use the records as picklist by List<selectoption>

nelnel

Thanks for the reply. But I need the field to be a picklist in product page, it's Salesforce default product page, not a custom visual force page, how do I use List<selectoption>?