You need to sign in to do that
Don't have an account?
K@S
between two dates get the all records start date and end date using search functionallty
Hi Team,
I got the errors, please help on this.
Apex class
[Error] Error: Compile Error: Variable does not exist: Start_Date__c at line 11 column 11
public class searchClientVisits{
List<Client_Visit__c> clientVisitList {get;set;}
public Client_Visit__c clientInfo { get;set; }
public SearchClientVisits(){
clientInfo = new Client_Visit__c ();
}
public PageReference runSearch(){
string query='SELECT Id,Start_Date__c,End_Date__c FROM Client_Visit__c WHERE CloseDate < LAST_FISCAL_QUARTER';
if(Start_Date__c == strtdate && End_date__c == enddate){
}
clientVisitList =database.query(query);
}
public PageReference reset(){
PageReference pg = new PageReference(System.currentPageReference().getURL());
pg.setRedirect(false);
return pg;
}
}
VF page
[Error] Error: Unknown property 'void.Start_Date__c'
<apex:page controller="searchClientVisits">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!clientInfo.Start_Date__c}" label="Start Date"/>
<apex:inputField value="{!clientInfo.End_Date__c }" label="End Date"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Reset" action="{!reset}"/>
<apex:commandButton value="Search" action="{!runSearch}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable value="{!clientVisitList }" var="client" id="clientList">
<apex:column value="{!client.Start_Date__c}" headerValue="Start Date"/>
<apex:column value="{!client.End_Date__c }" headerValue="End Date"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I got the errors, please help on this.
Apex class
[Error] Error: Compile Error: Variable does not exist: Start_Date__c at line 11 column 11
public class searchClientVisits{
List<Client_Visit__c> clientVisitList {get;set;}
public Client_Visit__c clientInfo { get;set; }
public SearchClientVisits(){
clientInfo = new Client_Visit__c ();
}
public PageReference runSearch(){
string query='SELECT Id,Start_Date__c,End_Date__c FROM Client_Visit__c WHERE CloseDate < LAST_FISCAL_QUARTER';
if(Start_Date__c == strtdate && End_date__c == enddate){
}
clientVisitList =database.query(query);
}
public PageReference reset(){
PageReference pg = new PageReference(System.currentPageReference().getURL());
pg.setRedirect(false);
return pg;
}
}
VF page
[Error] Error: Unknown property 'void.Start_Date__c'
<apex:page controller="searchClientVisits">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:inputField value="{!clientInfo.Start_Date__c}" label="Start Date"/>
<apex:inputField value="{!clientInfo.End_Date__c }" label="End Date"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Reset" action="{!reset}"/>
<apex:commandButton value="Search" action="{!runSearch}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable value="{!clientVisitList }" var="client" id="clientList">
<apex:column value="{!client.Start_Date__c}" headerValue="Start Date"/>
<apex:column value="{!client.End_Date__c }" headerValue="End Date"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Try with below code ,
All Answers
Problem in this line if(Start_Date__c == strtdate && End_date__c == enddate)
Could you please explain your requirment bit more so that we can help you .
whenever enter the start date and end date then click search button after retrive all records in between dates.
I changed this like
public PageReference runSearch(){
string query='SELECT Id,Accounts__c,Start_Date__c,End_Date__c FROM Client_Visit__c WHERE CloseDate < LAST_FISCAL_QUARTER';
if(clientInfo.Start_Date__c<System.Today() && clientInfo.End_Date__c >System.Today()){
}
Error: Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 15 column 7
but VF same error will be there
Thanks,
kae
Do you want to add three filter in your query like within startdate and end date , closeDate should less then last quarter ?
You have missed one thing you need to return null or some thing from that method
Please confirm .Also your start date and end date are DateTime or Date only ?
Try with below code ,
Change your method liek below and let me know if it helps !!
Try with below cod eit will help !!
Let me know if it helps !!
Thanks
Manoj
Try with belwo class code it wil help
Thank you very munch youe help.
I got the out put this like I has been changed.
//search the client records
public void runSearch(){
if(clientInfo.Start_Date__c != null && clientInfo.End_Date__c != null){
Date startDate=clientInfo.Start_Date__c;
Date endDate=clientInfo.End_Date__c;
clientvisitList = [SELECT Id,Accounts__c,Start_Date__c,End_Date__c,Clients__c,Locations__c FROM Client_Visit__c WHERE Start_Date__c <= :startDate AND End_Date__c >=:endDate];
System.debug('#####'+clientvisitList);
}
}
Thanks,
kae