I have created class using custom setting. I need to retrieve data from custom setting. I am getting constructor not defined error my error line is options.add(new SelectOption)Please find below code. How can I resolve this error. Please can any one suggest me.


public with sharing class CustomSettingsController {

    public string ISOCode {get;set;}
    public list<RFLEET_CS01_Grid_Protocol_Lines__c> options_list {get;set;}
    public list<RFLEET_CS01_Grid_Protocol_Lines__c> options_list_Split {get;set;}

     public String selectedIso {get;set;}

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

            for (RFLEET_CS01_Grid_Protocol_Lines__c iso : RFLEET_CS01_Grid_Protocol_Lines__c.getAll().values())

            options.add(new SelectOption(iso.Model__c,iso.Name+' - '+iso.Model__c));
            return options;


     public void getrecords(){

           options_list = new list<RFLEET_CS01_Grid_Protocol_Lines__c>();
           options_list= [SELECT Name,Model__c FROM RFLEET_CS01_Grid_Protocol_Lines__c WHERE Model__c = :ISOCode];

       public void SplitRecords(){

           options_list_Split = new list<RFLEET_CS01_Grid_Protocol_Lines__c>();

          //for (Country_Custom_Setting__c iso : Country_Custom_Setting__c.getAll().values())
           // options.add(new SelectOption(iso.Model__c,iso.Name));
             options_list_Split= [SELECT Name,Model__c FROM RFLEET_CS01_Grid_Protocol_Lines__c WHERE Model__c = :ISOCode];
             //return null;


  • 1
    Try this options.add(new SelectOption(''+iso.Model__c,iso.Name+' - '+iso.Model__c));
    – Ashwani
    Aug 21, 2015 at 9:24
  • @Ashwani thanku for quick response I am getting another Error: Invalid bind expression type of String @ another query line this line:options_list_Split...
    – Nikitha
    Aug 21, 2015 at 9:38
  • 1
    Try this then: options_list= [SELECT Name,Model__c FROM RFLEET_CS01_Grid_Protocol_Lines__c WHERE Model__c = :Integer.valueOf(ISOCode)];
    – Ashwani
    Aug 21, 2015 at 9:41
  • What data type is the Model field? Surely changing the definition of ISOCode from a String to the correct data type would be a better option
    – BarCotter
    Aug 21, 2015 at 9:46
  • 1
    Model is a checkbox?
    – BarCotter
    Aug 21, 2015 at 9:53

1 Answer 1


The SelectOption constructors signature is

public SelectOption(String value, String label)

Your error may be caused by the Model__c field, if it is not a String then you will get error you are seeing.

You could convert it to a String in the following way:


Be aware that if Model__c is null then the above line will result in the String 'null'

You must log in to answer this question.

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