Many a times we come across situations in which we want data to be added to a picklist dynamically.By saying dynamic i mean that you do not want an Administrator to go to the field level setup and add values to the picklist. Below is the sample code for you to understand
Controller
public class TestSelectController{
public List<SelectOption> getYears() {
List<SelectOption> options = new List<SelectOption>();
for (Integer i = System.Today().year() - 3; i < System.Today().year() + 3; i++) {
options.add(new SelectOption(String.valueOf(i), String.valueOf(i)));
}
return options;
}
public String selectedYear {get; set;}
public TestSelectController() {
selectedYear = String.valueOf(System.Today().year());
}
}
A dynamic picklist allows end users to add values to the list rather than requiring the assistnace of an administrator. It can be updated as and when values are required. This is particularly useful if you have processes within your organisation whereby you would have to request values to be added to a standard picklist. This could take some time and if you're in the middle of something, it would distract from what you're doing and delay things unnecessarily. This is a great post from Forcetree.com Salesforce Unearthed - Dynamically add values to picklist (http://www.forcetree.com/2009/06/dynamically-add-values-to-picklist.html). Please mark as best answer if this has resolved your query. Many thanks.
Many times we come across situations in which we want data to be added to a picklist dynamically.
By saying dynamic I mean that you do not want an Administrator to go to the field level setup and add values to the picklist... Please check the below link for detailed description and example
Many a times we come across situations in which we want data to be added to a picklist dynamically.By saying dynamic i mean that you do not want an Administrator to go to the field level setup and add values to the picklist. Below is the sample code for you to understand
Controller
Page
This blogpost (http://www.forcetree.com/2009/06/dynamically-add-values-to-picklist.html)helps you to get detailed information for more information.
Please mark this as the best answer if this helps
Many times we come across situations in which we want data to be added to a picklist dynamically.
By saying dynamic I mean that you do not want an Administrator to go to the field level setup and add values to the picklist...
Please check the below link for detailed description and example
http://www.forcetree.com/2009/06/dynamically-add-values-to-picklist.html
Example2:
Visualforce Page
Controller
Hope this helps you!
Best Regards,
Jyothsna