You need to sign in to do that
Don't have an account?
DeveloperSud
Visualforce Page: Redirect back to search result after clicking 'Back To Cases' link.
Hi Guys,
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added a filter 'Status' so that it can refine the case list based on requirement.Status options are 'New' and 'Resolved' Cases and after choosing any one of the option if I hit the search button it will show the list of cases based on the status.If no option is selected by default it will show the all cases in the list.
Now the requirement is if I apply case filter status as 'new' and if it retuns 4 cases, after clciking any one of that case it should redirect to the case detail page and after clicking the 'back to cases' command link in case detail page it should redirect back to refined serach result (it should show all that 4 cases in the list not all the cases) .I am giving my code here .Please help .thanks!!!
Need your help on the below situation.
I have a page which is showing "List of Cases" for my organisation.I have added a filter 'Status' so that it can refine the case list based on requirement.Status options are 'New' and 'Resolved' Cases and after choosing any one of the option if I hit the search button it will show the list of cases based on the status.If no option is selected by default it will show the all cases in the list.
Now the requirement is if I apply case filter status as 'new' and if it retuns 4 cases, after clciking any one of that case it should redirect to the case detail page and after clicking the 'back to cases' command link in case detail page it should redirect back to refined serach result (it should show all that 4 cases in the list not all the cases) .I am giving my code here .Please help .thanks!!!
<apex:page controller="testController100"> <apex:form > <apex:outputPanel > <apex:pageBlock title="List Of Cases For My Test Organisation" > <apex:outputLabel ><b> Status : </b></apex:outputLabel> <apex:selectList value="{!caseStatus1}" size="1"> <apex:selectOption itemvalue="NEW" /> <apex:selectOption itemvalue="RESOLVED" /> </apex:selectList> <apex:commandButton value="search" action="{!search}" /> </apex:pageBlock> </apex:outputPanel> </apex:form> <!--show the List of Cases --> <apex:form > <apex:outputPanel id="out1"> <apex:pageBlock > <apex:pageBlockTable value="{!listofcases}" var="lstofcases"> <apex:column > <apex:facet name="header" > <apex:commandLink value="Case" > </apex:commandLink> </apex:facet> <apex:outputLink value="/apex/casedetail?id={!lstofCases.Id}" id="theLink0" >{!lstofcases.CaseNumber}</apex:outputLink> </apex:column>
public with sharing class testController100 { public String caseStatus1{get;set;} public pagereference search(){ return null; } // code to show list of cases public List<case> getlistofcases(){ List<Case> listofcases=New List<Case>(); if(caseStatus1=='NEW'){ listofcases=[select casenumber,status,priority from case where status='New' order by status ASC]; } else if(caseStatus1=='Resolved'){ listofcases=[select casenumber,status,priority from case where status='Closed' order by status ASC]; } else{ listofcases=[select casenumber,status,priority from case where status='Closed' or status='New' order by status ASC]; } return listofcases; } }
<!-- Case detail page--> <apex:page standardController="case" extensions="testcontroller101"> <apex:form > <apex:outputpanel style="left-padding:600px" id="panelId"> <apex:commandLink value="Back To Case" style="color:blue ;font-size:16px" action="{!backurl}" /> <apex:pageBlock > <apex:pageBlockSection columns="2"> <apex:pageBlockSectionItem > <apex:outputLabel >Case #</apex:outputLabel> <apex:outputField value="{!CaseInfo.CaseNumber}" style="width:200px;" id="BCname"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Status</apex:outputLabel> <apex:outputField value="{!CaseInfo.Status}" style="width:200px;" id="CCategory"/> </apex:pageBlockSectionItem> </apex:pageblocksection> </apex:pageBlock> </apex:outputPanel> </apex:form> </apex:page>
public with sharing class testcontroller101 { public id caseId{get;set;} public Case CaseInfo { get; set; } public testcontroller101(ApexPages.StandardController stdController) { caseId = stdController.getRecord().Id; if(caseId!=null) { CaseInfo=[ select casenumber,Id,status From Case where id=:caseId]; system.debug('--CaseInfo--'+CaseInfo); } } public pagereference backUrl() { pagereference pg=new pagereference('/apex/page10'); return pg; } }
So you can send from and to date as a parameter of case Detail page: and in your casedetail page:
All Answers
In the above senario while clicking on "beck to Case" link the filter will vanish, because the "caseStatus1" variable has no value and the else part will execute which query all the cases.
So for now you can use URL parameters to achive you requirnment for that some changes required:
Create a constructor on testController100 Class which will used to check if url parameter has some value or not if yes then set it to "CaseStatus1" variable. and some chages needed on your caseDetail page's controller, Just add one parameter on returnUrl :
Thanks for your quick response.The code is working only when I am changing the status to ' New' not for 'Resolved'. I have changed in controller like below to fix this. Now can u pls tell me how to fix the issue if I add one more filter here. Please find my code below I have added a date range filter here.
Add another parameter in url like: and get the parameter value same as we did for status:
Here 'fDateValue' and 'tDateValue' both are using case 'createdDate' field value. so when redirecting back to List of cases page 'Date Range*' is taking the same value as 'To' date field.can u pls help how the the field value of 'date range' can be kept same?
So you can send from and to date as a parameter of case Detail page: and in your casedetail page:
Thanks a lot. This is working now .