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
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;
    }
}

 
Sahil Anand 2Sahil Anand 2
Hi Hitesh,
If you want to use Database.query() then please see the below code - 
public class NewCaseListController {
    public List<Case> getNewCases() {
        String varr = 'New';
        List<Case> results = Database.query('SELECT Id, CaseNumber FROM Case WHERE Status = :varr');
        return results;
    }
}

 
Drew Eidt (UWO Data)Drew Eidt (UWO Data)

Hello all,

I am new to this and understand all exept one thing. Why is value="{!NewCases}" in apex:repeat but the method name is getNewCases? How does the page know to call the getNewCases method?

Thank you very much!

Jake ViteJake Vite

Allo, 

Here is the code blocks that I personally used; you're going to want to format it to how you prefer to read it and paste it into your own session, of course. Tabs aren't too friendly when commenting code blocks :)

For the NewCaseList block I put: 

<apex:page controller="NewCaseListController"> <apex:pageBlock title="new Case List" id="cases_list">
 
<apex:repeat var="case" value="{!newCases}" rendered="true" id="rCases"> 
<p><apex:outputLink value="/{!case.ID}">{!case.CaseNumber}</apex:outputLink></p> 

</apex:repeat>
</apex:pageBlock> 
</apex:page>
And then for the NewCaseListController Apex block this should work:
public class NewCaseListController { public List<Case> getNewCases() { List<Case> results = [SELECT CaseNumber FROM Case WHERE status='New']; return results; } }