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
PedroLoPedroLo 

Search Functionality for Cases

Hello,

 

I'm trying to build a custom search functionality that displays the list of cases using a custom hierarchy we have set in our org. I was able to display the list of cases according to our requirements. I'm trying now to set up the search criteria and I'm having problems setting this up.

 

I'm using a custom controller to display the results so i simply added a section in my Visualforce page to slect some of the case fields the user would be able to set to filter the cases. In order to preserve the same look and field as for an actual case, I'm using a case variable to to display and capture the values for the filter criteria. When I first set up the fields using an actual case record (for testing purposes), this works fine and dsiplays the correct values. However, when I change the values and hit the view button to redisplay the data, the values for the filter fields do not change.

 

I have tried using a custom controller and a Visualforce page for this. I'm not to familiar with writing getter and setters but I sort of undertood from checking the documentationa and the blogs that I wouldn't have to write one in this case as I'm biding the variable in Visualforce to a Case object in the custom controller.

 

Any pointer would be greatly apprciate it.

 

Thanks,

 

Pedro

PedroLoPedroLo

I think the problem has to do with the fact that I'm using Immediate=TRUE on the button that triggers the search. I had to include this option in order to make the paging work after I included the search filters. This was the case whenever I use a field that corresponds to a list or the owner which includes a list to select either user or queue.

lnryanlnryan

Hi Pedro,

 

Have you worked with Apex Forms, Action Regions and OutPut panels in visual force before? I always find it helpful to set those up and make sure those general areas interact properly before moving forward.

 

If you've verified that interface behavior and are stiltl having trouble with your output values it could have something to do with how you're calling the Case Variables. In fact, you shouldn't be binding filtering elements in your form. You should set this up as properties in your controller separate from the case fields.

 

if you post your code, people might be able to help more specifically...

PedroLoPedroLo

Thanks, I will check on using Action Regions. I haven't worked a whole lot with Visualforce and I might be missing something really obvious.

 

The reason I was using a case to bind with the filetering was to have the same look and field as user would experience when actually creating or updatin a case record (i.e. the lookup to select the account name).

 

I will post the code soon, I just need to clean it up. I got messy after I started experimenting to solve the problem.

lnryanlnryan

We ran into a similar quandry a while back and what we did to compromise was pair a search box with a select option (we ultimately decided on radio buttons for the search results as the most intuitive for our users).

 

If it turns out the issue was just the action regions, though, you may still be able to use {!Case.Account}, just be sure your Case isn't bound to a real case record.

 

PedroLoPedroLo

Well, I tried playing around with the action regions but I was not able to make it work. I have it working for most cases (I had to remove the inmediate from the View button). However, when I introduce a select list to choose the desired record type to filter, the output no longer works (I have it commented in the attached Visualforce page).

 

Here is the VF page:

 

<apex:page standardController="Case" extensions="MyPagingController4" tabStyle="Case" showHeader="True">
    <apex:pageMessages />
    <apex:sectionHeader title="Cases List with Paging"></apex:sectionHeader>
    <apex:form style="width:750px;" id="all">
        <apex:pageBlock title="Search Criteria" id="pageBlock5" tabStyle="Case">
            <apex:pageBlockSection columns="1" showHeader="false" title="Search Criteria" id="search" collapsible="true">
                    <apex:inputtext value="{!searchCriteria}" style="width:200px;"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Filter Criteria" id="pageBlock" tabStyle="Case">
            <apex:pageBlockSection columns="2" showHeader="false" title="Filter Criteria" id="filter" collapsible="true">
                <apex:inputfield value="{!filterCriteria.caseInfo.Type}" style="width:200px;"/>
                <apex:inputfield value="{!filterCriteria.caseInfo.OwnerId}" required="false" style="width:200px;"/>
                <apex:inputfield value="{!filterCriteria.caseInfo.AccountId}" style="width:195px;"/>               
                <apex:inputfield value="{!filterCriteria.caseInfo.Algo_Risk_Service_Project__c}" style="width:215px;"/>
                <!--
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Case Type"/>
                    <apex:selectList id="rec" value="{!recordTypes}" multiselect="false" size="1" style="width:200px;">
                        <apex:selectOptions value="{!items}"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                -->
            </apex:pageBlockSection>         
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="View" action="{!ViewData}" id="theButton" rerender="results" immediate="false"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock title="Results" id="results">
            <div align="center" style="display:{!IF(NOT(ISNULL(cases)),'block','none')}">
            <apex:commandButton value="Previous" action="{!previousBtnClick}" disabled="{!previousButtonEnabled}" reRender="results" immediate="True"></apex:commandButton>
            <apex:commandButton value="Next" action="{!nextBtnClick}" reRender="results" disabled="{!nextButtonDisabled}" immediate="true"></apex:commandButton>
            <font size="1pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;
            <apex:outputLabel value="{!PageNumber}"/>&nbsp;of&nbsp;
            <apex:outputLabel value="{!totalPageNumber}"/>&nbsp;&nbsp;&nbsp;&nbsp;</font>
            </div>
            <br/><br/>
            <apex:pageBlockTable value="{!cases}" var="a" rendered="{!NOT(ISNULL(cases))}" columnsWidth="14px,25px,250px,12px,15px">
                <apex:column headerValue="Case">
                    <apex:outputText rendered="{!a.ParentID <> ''}">&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>
                    <apex:outputLink value="{!URLFOR($Action.Case.View,a.id)}">{!a.CaseNumber}</apex:outputLink>
                </apex:column>
                <apex:column headerValue="Case Type" value="{!a.Case_Type__c}"/>
                <apex:column headerValue="Subject" value="{!a.Subject}"/>    
                <apex:column headerValue="Status" value="{!a.Status}"/>
                <apex:column headerValue="Owner" value="{!a.Owner.Name}"/> 
            </apex:pageBlockTable>
            <div align="right" style="display:{!IF(NOT(ISNULL(cases)),'block','none')}">
            <br/>
            <font size="1pt">Page&nbsp;
            <apex:outputLabel value="{!PageNumber}"/>&nbsp;of&nbsp;
            <apex:outputLabel value="{!totalPageNumber}"/>&nbsp;&nbsp;&nbsp;&nbsp;</font>
            <apex:commandButton value="Previous" action="{!previousBtnClick}" disabled="{!previousButtonEnabled}" reRender="results">
            </apex:commandButton>
            <apex:commandButton value="Next" action="{!nextBtnClick}" reRender="results" disabled="{!nextButtonDisabled}" >
            </apex:commandButton>
            </div>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

I don't think the problem is with my controller as the values returned and the paging are working until the select list element is intoduced. I'm sure I'm missing something rather obvious.