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
Judhajit MandalJudhajit Mandal 

Auto populate Picklist Values


Hi,
I am a Salesforce newbie, and I want to auto populate a picklist in which I want the picklist values to come from a pre-created Table. Suggest if that can be done! And how.
Please explain in detail.
Thank You.
Anupam RastogiAnupam Rastogi
Hi Judhajit,

Can you explain the requirement? As I understand, you have a picklist field on some object for which you want to show the picklist values from a table defined in some other object.

AR
Judhajit MandalJudhajit Mandal
Hi Anupam,

It is kindof the way u understood it... I was wondering if at all it can be populated from a table in another object, and the same would reflect any changes made to the table. That is, if we insert or delete records or entries from the table, i want that the picklist values get changed accordingly (Maybe we can include a refresh button or something on the page where the picklist is to be populated)

Thanks!
Anupam RastogiAnupam Rastogi
The kind of field you are talking about is what I call a Dynamic Picklist field. It is based on a dynamically changing list of values (LOVs) that are maintained in another object and are not a static list of values as we usually define while creating a picklist field.

I guess we do not have any direct way to handle this requirement in Salesforce. But if we see it with a different perspective then we do have a solution.

We can create a lookup field that relates to a custom object which can maintain these dynamically changing values. So it works like this - 

1. Suppose on object A you have created this lookup field that relates to object B. Object B is a simple custom object that stores the LOVs and in general is not available to the end user. Only Admins can maintain (add, update or delete) LOVs.
2. When you create a new record on object A, a trigger can default this lookup field to some random value present in object B. (But make sure that this random value always exist in object B, else the trigger will error out.)
3. As and when the application Admin makes any changes in the LOVs present in object B, the changes will always be available in the lookup field present on object A.

I hope this provides you a way to handle this requirement.

AR

 - Do remember to like the reply (and/or mark it best answer) if you find it useful.
Judhajit MandalJudhajit Mandal
Actually I wanted a solution to dynamically populate the picklist values withut defining them statically like we do during the creation of the picklist, but WITHOUT using any lookup in that matter.

Can u plz look at this link and tell me if this can be helpful in any way?
http://www.salesforcefast.com/2011/06/get-picklist-values.html

Because I'm not quite savvy with where and how to use this mentioned code structure!

 
Anupam RastogiAnupam Rastogi
This code is basically pulling LOVs from the picklist of another field on another object. So I do not think it is catering to what you need - 
 - Dynamic LOVs
 - Auto Population

What's with not using Lookup. I find it suitable to handle similar needs for having Dynamic LOVs.

May be I do not have your complete requirement so as to visualize and suggest on your need.