public class getSpecialitiesForSelection {

    public List<SelectOption> sOptions {get;set;}
    public List<String> myString1 {get;set;}
    public List<String> myString2 {get;set;}
    String fieldname;
    String objectname;

    public getSpecialitiesForSelection(){
        sOptions = new List<SelectOption>();
        myString1 = new List<String>();
        myString2 = new List<String>();
        Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Specialty_1_vod__c;
        system.debug('Printing specialty values' + f);
        objectname ='Accounts';
        fieldname ='Specialty_1_vod__c';
        for(Schema.PickListEntry p : f.getPicklistValues()){
            sOptions.add(new SelectOption(p.getValue(), p.getLabel()));

        Schema.DescribeFieldResult f1 = Schema.sObjectType.Account.fields.Specialty_2_vod__c;
        objectname ='Accounts';
        fieldname = 'Specialty_2_vod__c';
        for(Schema.PickListEntry p1 : f1.getPicklistValues()){
            sOptions.add(new SelectOption(p1.getValue(), p1.getLabel()));



Above i modified the class and adding VF Page use - here teh problem is list is extracting twice, method is getting call two time, please let me know if something is wrong in below VF page

<apex:page controller="getSpecialitiesForSelection" cache="true" contentType="text/csv#Export.csv" language="en-US" >
"Object Name", "Field Name", "Picklist Value"
    <apex:repeat value="{!myString1}" var="a1" >
        <apex:repeat value="{!myString2}" var="a2">
"", "{!a1}" 
            <apex:repeat value="{!sOptions}" var="a"> 
, , {!a.value}, {!a.label}
  • 2
    The code to get Picklist values looks alright. Does the visualforce page have a repeat over the collection of SelectOptions ? Could you post the entire VF page with markup? Oct 8, 2012 at 22:16
  • 1
    What are you getting instead of CSV output? I would expect that, for one thing, it's all on one line, since there are no newlines. Oct 8, 2012 at 22:50
  • 1
    You really need to list a) what you've tried and b) what the error is. Right now this question is likely to be closed without more information.
    – Matt Lacey
    Oct 9, 2012 at 2:15
  • I need a simple extract of picklist values for all the picklist fields present in all the objects from my org.
    – user697
    Oct 9, 2012 at 21:27
  • 1
    If the title of your question is your question, you should also use the code highlight -- also you shouldn't post edits in answers to the questions. Oct 9, 2012 at 21:40

1 Answer 1


Your code that builds the list of selectOptions is fine, but never gets called, your VF page accesses sOptions, but nothing has set that until getSpecialitiesForSection() has run, change your apex code to

public class  getSpecialitiesForSelection {

    public list<SelectOption> getsOptions() {
        List<SelectOption> sOptions = new List<SelectOption> ();
        Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Industry;
        for(Schema.PickListEntry p : f.getPicklistValues()) {
            sOptions.add(new SelectOption(p.getValue(), p.getLabel()));
        return sOptions;

You must log in to answer this question.

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