+ Start a Discussion
Bhaskar ChowdaryBhaskar Chowdary 

I want to see open cases in my visualforce page

please find out and give a code "I want to display 1.all cases opened  2. open opp records in visualforce page please give code for those "

 

controllee is

 

global class CompanyCasesQue {
public string FilterId{get;set;}
public list<case> results;
    //constructors and variable declaration

    public PageReference renderdiffview() {
    Map<Id,string> Id_status_map = new map<Id,string>{'00BW0000000PeSVMA0' => 'New','00BW0000000PeSGMA0' => 'Closed'};
    results = [select id,casenumber from case where status =: Id_status_map.get(filterId)];
     return null;
    }

    public List<Case> getresults() {      
     return results;
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('00BW0000000PeSVMA0','View All Open Cases'));
        options.add(new SelectOption('00BW0000000PbzWMAS','View All Cases'));
        options.add(new SelectOption('00BW0000000PeSGMA0','View All Closed Cases'));
        options.add(new SelectOption('00B300000005XQtEAM','Recently Viewed Cases'));
        return options;
    }
}

 

page is

 

<apex:page controller="CompanyCasesQue" sidebar="true" showHeader="true">
    <apex:form >
        <apex:pageBlock title="Display the Cases ">
              <apex:outputLabel value="View:"/>
              <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" action="{!renderdiffview}" rerender="cases_table"/>
                <apex:selectOptions value="{!items}"/>
              </apex:selectList>
            <apex:pageBlock >
                <apex:pageBlockTable value="{!results}" var="c" rows="50" id="cases_table">
                    <apex:column >
                        <a target="_parent" href="/{!c.id}">{!c.CaseNumber}</a>
                        <apex:facet name="header">Case Number</apex:facet>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Ankit Gupta@ DeveloperAnkit Gupta@ Developer

Hi,

 

Try the below code sample as reference:

 

visualforce page

---------------------------------

<apex:page controller="displaycase">
 <apex:form id="frm">
 
 <apex:selectList size="1" value="{!getcasetype}" >
 <apex:selectOptions value="{!casestatus}"> </apex:selectOptions>
 <apex:actionSupport event="onchange" action="{!displaycaselist}"/>
 </apex:selectList>
 <apex:outputLabel id="pnl1" >
 <apex:pageBlock >
 <apex:pageBlockTable value="{!caselst}" var="cse">
 <apex:column value="{!cse.CaseNumber}"/>
 <apex:column value="{!cse.Subject}"/>
 <apex:column value="{!cse.Type}"/>
 <apex:column value="{!cse.Priority}"/>
 <apex:column value="{!cse.Reason}"/>
 <apex:column value="{!cse.Status}"/>
 <apex:column value="{!cse.IsEscalated}"/>
 <apex:column value="{!cse.IsClosed}"/>
 <apex:column value="{!cse.ClosedDate}"/>
 </apex:pageBlockTable>
 
 </apex:pageBlock>
 
 </apex:outputLabel>
 </apex:form>
</apex:page>

 

 

 

 

 

 

Apex class

------------------------------------

public class displaycase {
public string getcasetype{get;set;}
public  void displaycase ()
{
    
}
public list<case> caselst{get;set;}


public list<selectoption>getcasestatus()
{
    list<selectoption>selectopt=new list<selectoption>();
    selectopt.add(new selectoption('New','New'));
    selectopt.add(new selectoption('Working','Working'));
    selectopt.add(new selectoption('Escalated','Escalated'));
    selectopt.add(new selectoption('Closed','Closed'));
    return selectopt;
}
public void displaycaselist()
{
    caselst=new list<case>();
   caselst=[SELECT CaseNumber,ClosedDate,IsClosed,IsEscalated,Priority,Reason,Status,Subject,Type FROM Case where status=:getcasetype];
}
}

Krrish GopalKrrish Gopal
Hi Ankit,

Here I want to further refine my result on the basis of more standard picklist field Type, Reson, Origin and Priority at case object, what changes required in apex class.

Give me an example with 1 more piclist Type(I have Under Warranty, Under AMC and Out of Warranty values for type picklist at case object) rest I do it for balance.

Thanks in advance.
Krrish GopalKrrish Gopal
Here I also want to know how we can set default value for status piclist or any other picklist otherwise  no records will show on page when I see the page.