Error Error: Autocompletefields Compile Error: Method does not exist or incorrect signature: [Id].contains(String) at line 20 column 21

public class Autocompletefields {
     public AutoCompletefields(ApexPages.StandardSetController controller) {
       //Variable declaration
       transient public String[] jsonDescriptionData;
       //Constructor with argument as standrad controller
        public AutoCompletefields(ApexPages.StandardController controller) { }
        //Simple construcor
        public AutoCompletefields(){}
        //Method to return all nicopin for France user
        public List<string> getjsonDescriptionData(){
            jsonDescriptionData = new List<string>();
                //List of nicopin for france
                List<Quote__c> francePinCodeList=[SELECT Account_name__c FROM Quote__c LIMIT 50000];
                //Set to get all nico pin as string
                Set<String> pncodeSet=new Set<String>();
                 String quoteStr='"';
                //Iterate to collect set of all nico pin
                for(Quote__c cpnCod : francePinCodeList){
                    }//End of if
                }//End of for loop
                //Iterate to collect all pin in string format
                for(String str:pncodeSet){
                //To sort the nicopin list
                return jsonDescriptionData;
        }//End of method


can anybody correct this error ?

1 Answer 1


Id objects don't contain all the same methods as String objects. Cast one into the other first.

You could change your example to ((String)cpnCod.Account_name__c).contains(quoteStr)

  • if(!(((String)cpnCod.Account_name__c).contains(quoteStr))){
    – Teja
    Commented Dec 20, 2013 at 8:41
  • I am getting the error System.NullPointerException: Attempt to de-reference a null object line 20 column 1
    – Teja
    Commented Dec 20, 2013 at 8:42

You must log in to answer this question.

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