0

VF Page

<apex:page Controller="actionSupportController">
   <apex:form >
       <apex:pageBlock >
            Household Name: <apex:inputText value="{!ID_c}"/>          
           </apex:pageBlock>
    <apex:pageBlock title="Characteristics Information">

        <apex:inputCheckbox value="{!Active_c}" />Active<br/>
        <apex:inputCheckbox value="{!Good_with_Cats_c}" />Good with Cats<br/>
        <apex:inputCheckbox value="{!sct.HighNeed__c}" />HighNeed<br/>
        <apex:inputCheckbox value="{!sct.kid_friendly__c}" />Kid Friendly<br/>
        <apex:inputCheckbox value="{!sct.Non_shedder__c}" />Non Shedder<br/>
        <apex:inputCheckbox value="{!sct.Predatory_Tendencies__c}" />Prediator Tendency<br/>

       <br/><apex:commandButton value="Search" action="{!dochar}" rerender="sblck"/>
    </apex:pageBlock>
    <apex:outputPanel id="sblck">
    <apex:pageBlock title="Search Results">
    <apex:pageBlockTable width="80%" value="{!selctchr}" var="eachpe">
        <apex:column width="80%" value="{!eachpe.Name}"/>
         <apex:column width="80%" value="{!eachpe.Pet_ID__r.Name__c}"/>
        <apex:column width="80%" value="{!eachpe.Pet_ID__r.Gender__c}"/>
        <apex:column width="80%" value="{!eachpe.Pet_ID__r.Height__c}"/>       
        <apex:column width="80%" value="{!eachpe.Pet_ID__r.pet__c}"/>
        <apex:column width="80%" value="{!eachpe.Pet_ID__r.Pet_Photo__c}"/>
        <apex:column width="80%" value="{!eachpe.Pet_ID__r.Status__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:outputPanel>
       <apex:commandButton value="Request Adoption"/>
   </apex:form>
</apex:page>

Controller

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 List<Pets_Information__c> selctpet{get;set;}

    Public Boolean Good{get;set;}



    public void dochar(){
        string query='';
        system.debug('==sct.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 or +Active_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;
    }    
}
2
  • Please provide more details on what is the issue you are facing.
    – RajeshShah
    May 25 '16 at 5:21
  • i am getting this error "expecting a semi-colon, found 'or'"
    – muralimano
    May 25 '16 at 5:27
0

I feel below corrected version of query will work 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+'\' or Active__c=\''+Active_c+'\'';
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.