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
Brennan ButlerBrennan Butler 

Create a Visualforce page displaying new cases - Added help

I am about to rip my hair out, I have searched all the questions and answers I could find in the communit, and still can't get this to work. I think it is in the Apex Method, I am not sure what the code is there. and have not been able to find anything to reference to figure it out. Here is my code:

<apex:page controller="NewCaseListController" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Cases List" id="cases_list">            
            <apex:pageBlockTable value="{! Cases }" var="cs">
                    <apex:outputLink value="/!{cs.id}">{!cs.id}</apex:outputLink>
                          <apex:repeat value="{!Cases}" var="case" id="theRepeat">
                         </apex:repeat>
                <apex:column value="{! cs.CaseNumber }"/>
                <apex:column value="{! cs.id }"/>
                <apex:column value="{! cs.Status='New'}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image
Please help me. 
Thank you,
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for solution. I hope that will help you
https://developer.salesforce.com/forums/?id=906F0000000AzvMIAS
 
<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="Case_list">
            <!-- Case_list -->
         <apex:repeat value="{!Case}" var="cs">
            <apex:outputLink value="{!cs.Id}">{!cs.Id}</apex:outputLink>
            <apex:outputLink value="{!cs.CaseNumber}">{!cs.CaseNumber}</apex:outputLink>
        </apex:repeat>      
        </apex:pageBlock>
    </apex:form>
</apex:page>
Public class NewCaseListController {
List<Case> results = new List<Case>();


private String sortOrder = 'CaseNumber';
public List<Case> getCase() {
    
    results = [SELECT Id, CaseNumber FROM Case WHERE Status = 'New'];

    return results;
    }
}



 
Amit Chaudhary 8Amit Chaudhary 8

VISUALFORCE PAGE NewCaseList
<apex:page controller="NewCaseListController">
    <apex:form >

        <apex:pageBlock title="New Case List" id="cases_list">

            <apex:repeat value="{!newCases}" var="case" id="case">
                <p><apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink></p>
            </apex:repeat>

        </apex:pageBlock>

    </apex:form>

</apex:page>
CUSTOM CONTROLLER NewCaseListController
public class NewCaseListController {

    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Status ' +
            'FROM Case ' +
            'WHERE Status = \'New\' '
        );
   
    return results;
    }

}
Please let us know if this will help u

 
Chicky ChickenhawkChicky Chickenhawk
THANK YOU !!!! IT WORKS AS EXPECTED !!!!
Jeremy BeckerJeremy Becker
How many minutes did I spend stupidly not realizing it was a matter of escaping the quotes? Answer: Too many. 
Anne D PyleAnne D Pyle
This was helpful. I have two follow up questions.
  1. What is the difference between using the [SELECT...] statement as opposed to Database.query(...) in the apex controller. Is one better than the other? The first is easier.
  2. Is there a way to eliminate the bullets in the rendering of the Visualforce page?User-added image
Lisa Ryan 18Lisa Ryan 18
I have no hair left from pulling it all out over this challenge.  I've written it and run it and it does exactly what it is supposed to do.  But when I check the challenge it says: "Case records were not returned upon calling 'getNewCases'. Either the method does not exist, or it does not return the expected list of cases."  My controller:

public class NewCaseListController {
    public static List<Case> getNewCases()
    {
        List<Case> cases = Database.query(
            'SELECT Id, CaseNumber From Case WHERE Status=\'New\''
        );
        return cases;
    }
}

When I preview it, it looks fine shows me the four open cases and I can click through to the details.  VERY FRUSTRATING.  Please help!
Lisa Ryan 18Lisa Ryan 18
To follow up on this, I just tried randomly rewriting and changing things to get the challenge to pass.  It passes if the method is not static.  I waste so much time on answers to challenges that work and are clearly correct but do not exactly match what the challenge question author is looking for.  This is a real problem.  If the result set is returned correctly, details of implementation should be left to the developer.