+ Start a Discussion
Santi Ram RaiSanti Ram Rai 

Create a Visualforce page displaying new cases

Hi, I am doing Trialhead. But i stuck here. This is my error message:
User-added image

And my code is:
<apex:page controller="NewCaseListController" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Cases List" id="cases_list">            
            <apex:pageBlockTable value="{! NewCases }" var="cs">
                    <apex:outputLink value="{! cs.Id}">{! cs.Id}>
                          <apex:repeat value="{!newCases}" var="case" id="theRepeat">
                         </apex:repeat>
                    </apex:outputLink>
                <apex:column value="{! cs.CaseNumber }"/>
                <apex:column value="{! cs.id }"/>
                <apex:column value="{! cs.Status}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Best Answer chosen by Santi Ram Rai
Subodh shuklaSubodh shukla
<apex:outputLink value="/!{cs.id}">{!cs.id}</apex:outputLink>
try this...
 

All Answers

Subodh shuklaSubodh shukla
<apex:outputLink value="/!{cs.id}">{!cs.id}</apex:outputLink>
try this...
 
This was selected as the best answer
Virender Singh 8Virender Singh 8
VF page 
-----------------------

<apex:page controller="NewCaseListController" showHeader="false">
    <apex:repeat value="{!newCases}" var="case" id="theRepeat">
         <apex:outputLink value="/!{case.id}">{!case.id}</apex:outputLink>  
    </apex:repeat>
    
</apex:page>

CustomController
-------------------------------
public class NewCaseListController {

    public List<Case> getNewCases()
    {
        List<Case> lst = [Select CaseNumber from Case where status='New'];
        return lst;
     }
}
 
Muhammad AlaaMuhammad Alaa
Visualforce Page
<apex:page controller="NewCaseListController">
    <apex:pageBlock title="new Case List" id="cases_list">
        <li>
            <apex:repeat var="case" value="{!newCases}" rendered="true" id="rCases">
                <p><apex:outputLink value="/{!case.ID}">{!case.CaseNumber}</apex:outputLink></p>
            </apex:repeat>
		</li>
    </apex:pageBlock>
</apex:page>

Apex Class
public class NewCaseListController {
    public List<Case> getNewCases() {
    
        List<Case> results = [SELECT CaseNumber FROM Case WHERE status='New'];
            return results;
    }
}

 
Hitesh Khatri 13Hitesh Khatri 13

Hi,

I want to return my result with database.Querry(); method but it is showing error my visualforce page"

An unexpected error has occurred. Your development organization has been notified.". My code for it:-

public static List<Case> getNewCases(){
          List<Case> results = Database.query('SELECT CaseNumber FROM Case WHERE status=New');
    return results;
    }
Wrik BanerjeeWrik Banerjee
The controller code for me is as below:
public class NewCaseListController {
    private String val = 'New';
public List<Case> getNewCases() { 
        List<Case> results = Database.query(
        'SELECT Id, CaseNumber FROM Case WHERE Status = \'' + String.escapeSingleQuotes(val)+'\'');
    return results;
}
}

The VisualForce Page code using the above controller is as below:
<apex:page controller="NewCaseListController">
     <apex:pageblock title="New Cases List" id="cases_list"> 
        <apex:repeat var="case" value="{! newCases }" rendered="true"  id="case_list"  >
            <li>
                <apex:outputLink value="/{!case.ID}" >
                    <apex:outputText value="{!case.CaseNumber}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>        
    </apex:pageblock>
</apex:page>

With those 2 above, the trailhead challenge was passed. Hopefully it would help.
Jagannath Birajdar 23Jagannath Birajdar 23
Hi Wrik Banerjee,
your code helped me to complete challage.
anuroop sudanagunta 7anuroop sudanagunta 7
Page:
<apex:page controller="NewCaseListController" >
    <apex:repeat var="case" value="{!NewCases}">
        <apex:outputLink value="/{!Case.Id}"/>
    </apex:repeat>
</apex:page>
Controller:
public class NewCaseListController {
    Public  list<case> getNewCases(){
        List<Case> CsList = [Select id,CaseNumber from Case where Status='new'];
        return CsList;
    }
}