function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anurajanuraj 

Search date

Hi

 I have done a code which contain Date, Appointment type, Clint, Status. And it contain 4 text box. I want to search the Date, Appointment type, Clint, Status. I am able to search Appointment type, Clint, Status. But when I add search for Date all other are not able to work. 

Please help me.

 

This is my code

<apex:page controller="apposearchController" sidebar="false">
  <apex:form > 
     <apex:pageMessages id="errors" />
      <apex:pageBlock title="Appoinment!" mode="edit">
        <table>
            <tr>
                <td width="200" valign="top">
                <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                    <script type="text/javascript">
                              function doSearch() {
                                searchServer(
                                document.getElementById("AppoinmentType").value,
                                document.getElementById("Clint").value,
                                document.getElementById("StartDate").value,
                                document.getElementById("Status").options[document.getElementById("Status").selectedIndex].value
                                );
                              }
                        </script>
                        
                        <script type="text/javascript" src="clear-default-text.js"></script>
                        
                        <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                         <apex:param name="AppoinmentType" value="" />
                         <apex:param name="Clint" value="" />
                         <apex:param name="StartDate" value="" />
                         <apex:param name="Status" value="" />
                        </apex:actionFunction>
                         
                         <table cellpadding="2" cellspacing="2">
                             <tr>
                            <td style="font-weight:bold;">Appoinment Type<br/>
                            <input type="text" id="AppoinmentType" onchange="doSearch();" class="cleardefault"/>
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Clint<br/>
                            <input type="text" id="Clint" onchange="doSearch();" class="cleardefault"/>
                            
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Start Date<br/>
                           <!-- <html>
                                <head> -->
                                  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
                                  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
                                  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
                                  
                                  <script>
                                      $(document).ready(function() {
                                        $("#datepicker").datepicker();
                                      });
                                  </script>
                                      <!--  </head>
                                        <body style="font-size:80.5%;"> -->
                                          <!-- <div id="datepicker"></div>
                                           <div id="datepicker"><input type="text" id="datepicker" onchange="doSearch();" class="cleardefault"/></div> -->
                                  <div ><input type="text" id="datepicker" onchange="doSearch();" class="cleardefault"/></div>
                                       <!-- </body>
                                    </html>-->
                                  <!--  <input type="text" id="StartDate" onchange="doSearch();" class="cleardefault"/>
                                    <apex:inputField value="{!appoit.Start_Date__c}"  onchange="doSearch();"/>-->
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Status<br/>
                              <select id="Status" onchange="doSearch();">
                                <option value=""></option>
                                <apex:repeat value="{!Status}" var="tech">
                                  <option value="{!tech}">{!tech}</option>
                                </apex:repeat>
                              </select>
                            </td>
                          </tr>
                        </table>
                </apex:pageBlock>
                </td>
                <td valign="top">
                    <apex:pageBlock mode="edit" id="results">
                         <apex:pageBlockTable value="{!Appoinment}" var="Appointment">
                             <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="AppoinmentType" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Appointment_Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Appointment_Type__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Clint" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Client__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Client__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="StartDate" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Start_Date__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Start_Date__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Status" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Status__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Status__c}"/>
            </apex:column>
                         </apex:pageBlockTable>
                    </apex:pageBlock>
                </td>
            </tr>
        </table>      
    
           <apex:pageBlock title="Debug - SOQL" id="debug">
              <apex:outputText value="{!debugSoql}" />           
          </apex:pageBlock>
          

          
          </apex:pageBlock>
    
  </apex:form>
</apex:page>
public class apposearchController{
   // public String appoit { get; set; }    public List<Appointment1__c> Appoinment{get;set;}    private String soql {get;set;}    public String technologies { get; set; }       public String sortDir     {        get  { if (sortDir == null) {  sortDir = 'asc'; }                 return sortDir;      }                set;    }        public String sortField {    get  { if (sortField == null) {sortField = 'Appointment_Type__c'; }           return sortField;      }       set;    }        public String debugSoql {    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }    set;      }          public apposearchController() {    //delete(soql);    soql = 'select Appointment_Type__c, Client__c, Start_Date__c, Status__c, Client_First_Name__c from Appointment1__c where Client_First_Name__c!= null';    System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Appoinment '+ Appoinment);    System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++'+ soql  );    runQuery();      }             public void toggleSort()     {        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';                 runQuery();            }
  //  public List<Appointment1__c> appo {get;set;}
    public String getStatus() {        return null;    }

    public void runQuery() {         try     {     string a=soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20';     system.debug(a);      Appoinment = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Appoinment '+ Appoinment);     }     catch (Exception e)     {      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));    }    }       public PageReference runSearch()     {         String AppoinmentType;     String Clint;     String  StartDate;     String Status;     String  datepicker;     Date myDate;      datetime newdate;            AppoinmentType = Apexpages.currentPage().getParameters().get('AppoinmentType');     System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++AppoinmentType '+ AppoinmentType);     Clint = Apexpages.currentPage().getParameters().get('Clint');     System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Clint '+ Clint);          StartDate = Apexpages.currentPage().getParameters().get(StartDate);     if (datepicker != null)     myDate = date.valueOf(datepicker);    // newdate = myDate.substring(0,10);    // trim(myDate);    // System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++StartDate '+ StartDate);   //  System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++newdate '+ newdate);    // System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++myDate  '+ myDate);         Status = Apexpages.currentPage().getParameters().get('Status');     soql = 'select Appointment_Type__c, Client__c, Start_Date__c, Status__c, Client_First_Name__c from Appointment1__c where Client_First_Name__c != null';       if (!AppoinmentType.equals(''))      soql += ' and Appointment_Type__c  LIKE \''+String.escapeSingleQuotes(AppoinmentType)+'%\'';      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++AppoinmentType '+ AppoinmentType);    if (!Clint.equals(''))      soql += ' and Client_First_Name__c  LIKE \''+String.escapeSingleQuotes(Clint)+'%\'';      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Clint '+ Clint);     if (StartDate != null)     soql += ' and  Start_Date__c = ' + myDate;          //if (StartDate != null)    // soql += ' and  Start_Date__c = ' + myDate ;   //  System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Appoinments.Start_Date__c '+ Appoinments.Start_Date__c);     //soql += ' and Start_Date__c = \'' + myDate + '\'';     // soql += ' and Start_Date__c = '+ myDate + '' ;     //integer year = myDate.year();    // integer month = myDate.month();    // integer day = DAY_ONLY(myDate);          //  soql += ' and Start_Date__c equals (\''+myDate+'\')';    //  soql += ' and Client_First_Name__c  LIKE \''+date.escapeSingleQuotes(myDate)+'%\'';      // System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++myDate '+ myDate);     if (!Status.equals(''))     soql += ' and Status__c LIKE \''+String.escapeSingleQuotes(Status)+'%\'';     System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Status'+ Status);             runQuery();        return null;     }           public List<String> Status        {            get             {            if (Status == null)             {            Status = new List<String>();            Schema.DescribeFieldResult field = Appointment1__c.Status__c.getDescribe();                 for (Schema.PicklistEntry f : field.getPicklistValues())            Status.add(f.getLabel());          }          return Status;                  }        set;            }
}

 

thanks

Anuraj

spraetzspraetz

Need better formatting of your controller block.

 

can't read any of that.