1
public with sharing class CustomSettingsListController {

  public String selectedStage {get;set;}

  public List<selectOption> leadStages {
    get {
      List<selectOption> options = new List<selectOption>();
      for (LeadSquared__Change_Lead_Stage_to__c stage : LeadSquared__Change_Lead_Stage_to__c.getAll().values()){
            options.add(new SelectOption(String.valueOf(stage.LeadSquared__Lead_Stage__c)));
      }
      return options;
    }
    set;
  }
}

I am getting the following error

Constructor not defined: [System.SelectOption].<Constructor>(String)

2 Answers 2

3

As you can see here: The SelectOption class has two different constructors. One accepts two parameters, the other three parameters.

In your code you instanciate the selectOption with only one parameter.

You have to do:

options.add(new SelectOption('YourValue', String.valueOf(stage.LeadSquared__Lead_Stage__c)));
1

Select option class constructor expect two parameter

SelectOption option = new SelectOption(value, label);

So update you code as shown below.

public with sharing class CustomSettingsListController {

  public String selectedStage {get;set;}

  public List<selectOption> leadStages {
    get {
      List<selectOption> options = new List<selectOption>();

        for (LeadSquared__Change_Lead_Stage_to__c stage : LeadSquared__Change_Lead_Stage_to__c.getAll().values()){
        options.add(new SelectOption(String.valueOf(stage.LeadSquared__Lead_Stage__c),String.valueOf(stage.LeadSquared__Lead_Stage__c)));
        }
      return options;

    }
    set;
  }

}

You must log in to answer this question.

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