0

i want select query for multiple checkbox but I am getting an error

System.QueryException: unexpected token: 'true' Error is in expression '{!dochar}' in component in page cc: Class.actionSupportController.dochar: line 24, column 1

public class actionSupportController {
    public List<PCS_Household__c> lstQuery{get;set;} 
    public List<PCS_Household__c> OnlstQuery{get;set;}
    public List<Characteristics__c> selctchr{get;set;}
    public Characteristics__c sct{get;set;}
    public string ID_c{get;set;}      
    public string test{get;set;}
    public string Good_with_Cats_c{get;set;}    
    public string Active_c{get;set;}
    public string HighNeed_c{get;set;}    
    public string kid_friendly_c{get;set;}
    public string Non_shedder_c{get;set;}    
    public string Predatory_Tendencies_c{get;set;}

    public List<Pets_Information__c> selctpet{get;set;}

    Public Boolean Good{get;set;}

    public void dochar(){
        string query='';
        system.debug('==Good_with_Cats_c=='+Good_with_Cats_c);
        query='SELECT Name,ID,Good_with_Cats__c,Pet_ID__r.Gender__c,Pet_ID__r.Height__c,Pet_ID__r.Name__c,Pet_ID__r.pet__c,Pet_ID__r.Pet_Photo__c,Pet_ID__r.Status__c FROM Characteristics__c where Good_with_Cats__c\''+Good_with_Cats_c+'\'';
        system.debug('==query=='+query);
        selctchr=Database.query(query);    
        system.debug('==selctchr=='+selctchr);
    }


    public PageReference incrementCounter() {
       string Query='';
        Query='SELECT ID,Name,Household__c,Phone__c,of_Childrens__c,of_Exiting_Pets__c,Address__c,Previous_Dog__c FROM PCS_Household__c where ID=:test';        
        system.debug('==Query=='+Query);
        OnlstQuery=Database.query(Query);
        system.debug('==OnlstQuery=='+OnlstQuery);
        return null;
    }

     public Void doSearch(){
        string Query='';
        Query='SELECT ID,Name,Household__c,Phone__c,of_Childrens__c,of_Exiting_Pets__c,Address__c,Previous_Dog__c FROM PCS_Household__c where Household__c LIKE \'%'+ID_c+'%\'';
         system.debug('==ID_c=='+ID_c);
        system.debug('==Query=='+Query);
        lstQuery=Database.query(Query);
        system.debug('==lstQuery=='+lstQuery);
    }

    public void nullify(){
        lstQuery.clear();
    }

    public PageReference nextpage() {

        upsert OnlstQuery;

        return Page.cc;
    }

}
0

I feel below query will work fine for you :

query='SELECT Name,ID,Good_with_Cats__c,Pet_ID__r.Gender__c,Pet_ID__r.Height__c,'+
       ' Pet_ID__r.Name__c,Pet_ID__r.pet__c,Pet_ID__r.Pet_Photo__c,Pet_ID__r.Status__c'+
       ' FROM Characteristics__c where Good_with_Cats__c ='+Good_with_Cats_c;
  • what mistake in my query ? – user31850 May 25 '16 at 14:30
0

Your query in the function dochar() has a problem. You forgot to put the = between Good_with_Cats__c and Good_with_Cats_c

query = 'SELECT Name, ID, Good_with_Cats__c, Pet_ID__r.Gender__c, Pet_ID__r.Height__c, Pet_ID__r.Name__c, Pet_ID__r.pet__c, Pet_ID__r.Pet_Photo__c, Pet_ID__r.Status__c FROM Characteristics__c WHERE Good_with_Cats__c = ' + Good_with_Cats_c;
  • again i am getting error System.QueryException: value of filter criterion for field 'Good_with_Cats__c' must be of type boolean and should not be enclosed in quotes – user31850 May 25 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy