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
Lohith MatamLohith Matam 

vf with controller

Create a Visualforce page that uses a custom controller to display a list of cases with the status of 'New'.The page must be named 'NewCaseList'.
The custom controller Apex class must be named 'NewCaseListController'.
The 'NewCaseListController' Apex class must have a publically scoped method named 'getNewCases'.
The 'getNewCases' Apex method should have the return type of 'List' and return a list of case records with the ID and CaseNumber fields and filtered to only have a status of 'New'.
The 'NewCaseList' Visualforce page must use an apex:repeat component which is bound to 'newCases'.
The apex:repeat component must refer to the var attribute as 'case'.
Within the apex:repeat component, bind a apex:outputLink component to the ID of the case so that the page directs the user to the detail page of the respective case record
andy81andy81
HIt Like If this Solves your issue so that others will have reference for it.
VF Page

<apex:page controller="NewCaseListController">
  <apex:repeat value="{!NewCases}" var="Case">

<apex:outputLink onclick="/?id={!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>
  </apex:repeat>
  
</apex:page>

Controller:-

public with sharing class NewCaseListController {
    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Origin, Status, Account.Name ' +
            'FROM Case ' +
            'LIMIT 10'
    );
    return results;
}

}
Charles FortuneCharles Fortune
Slight modification to get link working w/ some formatting. Other than that, all else worked great!!

<apex:page controller="NewCaseListController">
  
    <apex:repeat value="{!NewCases}" var="Case">
        <li>
        <apex:outputLink value="/{!Case.Id}">{!Case.CaseNumber}</apex:outputLink>
          </li>
    </apex:repeat>
          
</apex:page>
SWETA SINGH 35SWETA SINGH 35
Hello all,I have cleared this trail..Please find the correct code below:

<apex:page controller="NewCaseListController">
  <apex:repeat var="case" value="{!NewCases}">
  <li>
  <apex:outputLink value="/{!case.id}">{!case.id}</apex:outputLink>
    {!case.CaseNumber}
  </li>

  
   
  </apex:repeat>
 
 
</apex:page>

( Write the below code Inside the apex class)

public class NewCaseListController {

list<case> newcase = new list<case>();
    public list<case> GetNewCases() 
    {
    newcase = [Select Id,CaseNumber from case where status='New'];
    
        return newcase;
    }


   

}
Ilya IvanovskiyIlya Ivanovskiy
<apex:page controller="NewCaseListController">
    <apex:repeat var="case" value="{!NewCases}">
        <li>
            <apex:outputLink value="/{!case.id}">{!case.id}</apex:outputLink>
            - {!case.CaseNumber}
            - {!case.Account.Name}
        </li>
    </apex:repeat>
</apex:page>
public class NewCaseListController {    
    private String sortOrder = 'CaseNumber';     
    public List<Case> getNewCases() {        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Account.name ' +
            'FROM Case ' +
            'ORDER BY ' + sortOrder + ' ASC ' 
        );
        return results;  
    }    
}

Visualforce Basics  Create & Use Custom Controllers
 
Soumyadip SomadderSoumyadip Somadder
Hi,
Please find my codes

Vf Code

<apex:page controller="NewCaseListController">
    <apex:form>
        <apex:pageBlock title="Case List" id="cases_list">
         <apex:repeat values="{!NewCases}" var="Case">
                 <apex:outputLink value="/{!Case.Id}">{!Case.CaseNumber}</apex:outputLink>
          </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Code

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

Whenever I amexecuting the code , I am receiving this error 

"Unsupported attribute values in <apex:repeat> in NewCaseList at line 6 column 56"

Can anyone put some light on it.

Thanks
Soumyadip

 
Monika Pawar 9Monika Pawar 9
For the Vf Page-:

<apex:page Controller="NewCaseListController " >
    <apex:repeat value="{!newCases}" var="case" id="theRepeat">
    <li><apex:outputLink value="/{!case.id}">{!case.ID }</apex:outputLink></li>
         <li><apex:outputLink value="/{!case.id}">{!case.CaseNumber }</apex:outputLink></li>
    </apex:repeat>
</apex:page>



For The Apex Class-:

public class NewCaseListController
{    
    private String sortOrder = 'CaseNumber';     
    public List<Case> getNewCases() {        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Account.name ' +
            'FROM Case ' +
            'ORDER BY ' + sortOrder + ' ASC ' 
        );
        return results;  
    }    
}
Zoltán AntalZoltán Antal

Hello Trailblazers!

In that challenge there is a small bug. The challenge ask a case list filtered by New. However it accept the challenge without filter. So...

For the VF Page:
<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="case_list">
            
            <!-- Case List goes here -->
            <apex:repeat value="{! newCases }" var="case">
                <li><apex:outputLink value="/{!case.id}">{!case.CaseNumber}</apex:outputLink></li>
            </apex:repeat>

        </apex:pageBlock>
    </apex:form>
</apex:page>

For the Apex class:
public class NewCaseListController {

    public List<Case> getNewCases() {        
        List<Case> newCases = Database.query('SELECT Id, CaseNumber FROM Case');
        return newCases;
    }

}

 

Chhavi Singhal 13Chhavi Singhal 13
Hello Everyone,
I tried this and it works perfect.See if this can help you.
VISUALFORCE PAGE :-
<apex:page controller="NewCaseListController">
    <apex:pageBlock title="Case List with Status as New">
        <apex:pageBlockSection >
            <!-- Case List with Status=New --> 
            <apex:repeat value="{!NewCases}" var="case">
                <apex:outputLink value="/{!case.ID}">
                    <apex:outputText value="{!case.casenumber}"/>
                </apex:outputLink> 
            </apex:repeat> 
        </apex:pageBlockSection> 
    </apex:pageBlock> 
</apex:page>

NewCaseListController CLASS :-
public class NewCaseListController 
{    
    List<Case> results=new List<Case>();
	public List<Case> getNewCases() 
    {
    	results=[Select ID,CaseNumber from Case where Status='New'];
    	return results;
	}
}

Thanks,
Chhavi Singhal​​​​​​​
​​​​​​​
Evaristo CaraballoEvaristo Caraballo

Hi People,

 

I have seen the code used to solve this particular problem but I don't understand why this works.

Is {!NewCases} the call for the public method in NewCaseListController class, GetNewCases? Is Get a keyword in Apex?

Thanks in advance for your comments here.

 

Naveen Reddy BeeramNaveen Reddy Beeram
Plz help me......

Create a Visualforce page that uses a custom controller to display a list of cases with the status of New.
Apex class:

public class NewCaseListController {
    public List<Case> getNewCases(){
        List<Case> Cases =[SELECT Id,CaseNumber From Case Where      status='New'];
        return Cases;
    }
}

Visual Page:

<apex:page controller="NewCaseListController">
  <apex:repeat value="{!NewCases}" var="Case">

<apex:outputLink onclick="/?id={!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>
  </apex:repeat>
  
</apex:page>

Error:

Challenge not yet complete in naveen98k@salesforce.com
The method 'getNewCases' isn't working as expected. Either the method doesn't exist or it doesn't return the expected list of cases.


Plz help me......
Surya Pratap Singh 13Surya Pratap Singh 13
This is perfectly working.. Mark it correct if you find it right

Vf :-
<apex:page controller="NewCaseListController">
 
        <apex:repeat value="{! NewCases}" var="case">
            <li>><apex:outputLink value="/{!case.id}" target="_new">Case {! case.caseNumber}   
                </apex:outputLink>   </li> 
            </apex:repeat>
    
     </apex:page>

Apex :-
public class NewCaseListController {

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

}

​​​​​​​
Varalakshmi Niharika JaguVaralakshmi Niharika Jagu
Use the following code to get 100% in your challenge!

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


NewCaseList (page)
<apex:page controller="NewCaseListController">
    <apex:form>
    	<apex:pageBlock title="Case List" id="cases_list">
        	<apex:repeat value="{! newcases}" var="case">
            	<li>
                    <apex:outputLink value="/{! case.Id}" target="_new">Case {! case.CaseNumber}
                    </apex:outputLink>
                </li>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Ani HemrakulyevichAni Hemrakulyevich

@urya Pratap Singh 13 I'm still having same problem. 

not sure whats going on. but when clicking view it shows all new cases. but challenge is still showing that above error message.
Any idea?
Thanks in advance...

Mohammad Imran KhanMohammad Imran Khan
Hi Everyone,
I have recently tried this and it works perfect. Hope will help you.
VF Page :-
<apex:page controller="NewCaseListController">
    <apex:form >
    <apex:pageBlock title="New Case List">
            
    <ul>
        <apex:repeat value="{!NewCases}" var="case">
            <li>
            <apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink>
              </li>
        </apex:repeat>
    </ul>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:
public class NewCaseListController {
    public List<Case> getNewCases() {
        List<Case> resultList = [Select Id,CaseNumber from case where status='New'];
        return resultList;
    }
}

If you find it as a solution, please mark it correct.
Tony Collings 7Tony Collings 7
VF Page
<apex:page controller="NewCaseListController">
  <apex:repeat var="case" value="{!NewCases}">
  <li>
      <!-- This works, but will fail the Trailblazer verification -->
    <!-- 
    <apex:outputLink value="{! URLFOR($Action.Case.View, case.id)}">{!case.CaseNumber} - {!case.Subject}</apex:outputLink> 
    -->
     <apex:outputLink value="/{!case.Id}">{!case.CaseNumber} - {!case.Subject}</apex:outputLink>
      
  </li>
  </apex:repeat>
</apex:page>

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

}