• Abhishek Yadav 73
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
//The custom controller is as given below

public class practice {
    
    public String SearchText {get; set;}
    
    public List<Task_Tracker__c> TrackList {get; set;}
    public PageReference doSearch(){
        List<List<sobject>> records = new List<List<sobject>>();
        List<Task_Tracker__c> NewList= new List<Task_Tracker__c>();
        
        //SEARCH FOR STARTDATE
        IF(SearchText.contains('/'))
        {
            Date dat = Date.parse(SearchText);
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where StartDate__c = :dat];
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where ClosedDate__c = :dat];
            TrackList = NewList;
            
        }
        
        
        
        //SEARCH FOR STATUS  
        else If(SearchText=='In Progress'|| SearchText=='New'||  SearchText=='On Hold' ||  SearchText=='Not Started'||
                SearchText=='Reassigned' || SearchText=='Rejected'|| SearchText=='Closed' || SearchText=='Escalated')
        {
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where Status__c = :SearchText];
            TrackList = NewList;
            
        }
        
        //SEARCH FOR PRIORITY
        else If(SearchText=='High'|| SearchText=='Medium'||  SearchText=='Low' )
        {
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where Priority__c = :SearchText];
            TrackList = NewList;
            
        }
        else
        {
            
            //SERACH FOR RESOURCEEMAIL OR NAME
            
            records = [FIND :SearchText RETURNING Task_Tracker__c(Name,Project__c,Description__c,Priority__c,
                                                                  ClosedDate__c,StartDate__c)] ;
            TrackList=records[0];
            
        }
        //List of sobject, so records will be of tt
        return null;
    }      
}


//AND THE VF PAGE GOES LIKE THIS

<apex:page controller="practice">
    <apex:form >
              <apex:pageBlock >
              <apex:pageBlockSection title="Search Candidate">
              <apex:inputText label="Enter Search Text" value="{!SearchText}"/>
              <!--         <apex:inputText label="Enter Search Text" value="{!SearchDate}"/>-->
               <apex:commandButton value="Do Search" action="{!doSearch}" reRender="cd"/>
                <!--reReder to identify what to refresh-->
            </apex:pageBlockSection>
            <!--id to identify what to refresh --implementation of ajax-->
            <apex:pageBlockSection title="Search Details" id="cd">
                <apex:pageBlockTable value="{!TrackList}" var="can">
                             <apex:column value="{!can.Name}"/>
                    <apex:column value="{!can.Project__c}"/>
            <!--        <apex:column value="{!can.Status__c}"/>-->
                   <apex:column value="{!can.Description__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
              </apex:pageBlock>
    </apex:form>
</apex:page>

//Can anybody hel;p me out with the test class please
//The custom controller is as given below

public class practice {
    
    public String SearchText {get; set;}
    
    public List<Task_Tracker__c> TrackList {get; set;}
    public PageReference doSearch(){
        List<List<sobject>> records = new List<List<sobject>>();
        List<Task_Tracker__c> NewList= new List<Task_Tracker__c>();
        
        //SEARCH FOR STARTDATE
        IF(SearchText.contains('/'))
        {
            Date dat = Date.parse(SearchText);
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where StartDate__c = :dat];
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where ClosedDate__c = :dat];
            TrackList = NewList;
            
        }
        
        
        
        //SEARCH FOR STATUS  
        else If(SearchText=='In Progress'|| SearchText=='New'||  SearchText=='On Hold' ||  SearchText=='Not Started'||
                SearchText=='Reassigned' || SearchText=='Rejected'|| SearchText=='Closed' || SearchText=='Escalated')
        {
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where Status__c = :SearchText];
            TrackList = NewList;
            
        }
        
        //SEARCH FOR PRIORITY
        else If(SearchText=='High'|| SearchText=='Medium'||  SearchText=='Low' )
        {
            NewList = [select Name,Project__c,Description__c,Priority__c,
                       ClosedDate__c,StartDate__c from Task_Tracker__c where Priority__c = :SearchText];
            TrackList = NewList;
            
        }
        else
        {
            
            //SERACH FOR RESOURCEEMAIL OR NAME
            
            records = [FIND :SearchText RETURNING Task_Tracker__c(Name,Project__c,Description__c,Priority__c,
                                                                  ClosedDate__c,StartDate__c)] ;
            TrackList=records[0];
            
        }
        //List of sobject, so records will be of tt
        return null;
    }      
}


//AND THE VF PAGE GOES LIKE THIS

<apex:page controller="practice">
    <apex:form >
              <apex:pageBlock >
              <apex:pageBlockSection title="Search Candidate">
              <apex:inputText label="Enter Search Text" value="{!SearchText}"/>
              <!--         <apex:inputText label="Enter Search Text" value="{!SearchDate}"/>-->
               <apex:commandButton value="Do Search" action="{!doSearch}" reRender="cd"/>
                <!--reReder to identify what to refresh-->
            </apex:pageBlockSection>
            <!--id to identify what to refresh --implementation of ajax-->
            <apex:pageBlockSection title="Search Details" id="cd">
                <apex:pageBlockTable value="{!TrackList}" var="can">
                             <apex:column value="{!can.Name}"/>
                    <apex:column value="{!can.Project__c}"/>
            <!--        <apex:column value="{!can.Status__c}"/>-->
                   <apex:column value="{!can.Description__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
              </apex:pageBlock>
    </apex:form>
</apex:page>

//Can anybody hel;p me out with the test class please