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
Ronan O'NeillRonan O'Neill 

Trailhead Creating and using Custom Controllers Challenge Issue

I'm getting the error "The outputLink component is not binding to the ID of a case" for this challenge. I've checked several threads on here and I'm almost certain it should be correct. It does link to the details page for the case. 

I initially just had the ID linking but have changed it so both case number and id link via id in case that mattered. 

I've also previously tried having a complete url as the value but no luck. 

Any help would be appreciated.

<apex:page controller="NewCaseListController">
 
        <apex:pageBlock title="New Case List" id="cases_list">
            
    <apex:repeat value="{! newcases }" var="cases">
       
        <apex:outputLink value="/{! cases.id}">
        ID:  {! cases.id }
        </apex:outputLink><br/>
        <apex:outputLink value="/{! cases.id}">
        Case Number:  {! cases.CaseNumber }
        </apex:outputLink><br/>    
    
    </apex:repeat>
            
        </apex:pageBlock>
Best Answer chosen by Ronan O'Neill
Sakthivel ThandavarayanSakthivel Thandavarayan
Try with variable name "Case" instead of cases.



<apex:repeat var="case" value="{!NewCases}">

All Answers

kumar tanwarkumar tanwar
Hello Ronan O'Neill,
Can you paste here Controller Code..
I am trying with below code its working fine..
Vf:-
<apex:page controller="Test">
<apex:pageBlock >
    <apex:outputLink value="/{!c.Id}" >Back</apex:outputLink>
</apex:pageBlock>
</apex:page>

Controller:-

public with sharing class Test { public Case c {get;Set;}     public Test(){         c = [select id from case limit 1];              } }

Thanks..
 
Ronan O'NeillRonan O'Neill
My controller code 

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

}

But just to stress, its the Challenge check on the Trailhead that is failing with the message "The outputLink component is not binding to the ID of a case". The page loads fine for me and the links do redirect to the case details page. 
kumar tanwarkumar tanwar
Hello Ronan,
I try with this code its work fine..
Thanks..
Sakthivel ThandavarayanSakthivel Thandavarayan
Try with variable name "Case" instead of cases.



<apex:repeat var="case" value="{!NewCases}">

This was selected as the best answer
Ronan O'NeillRonan O'Neill
Yep, That got it. Thank you very much. I was apparently blind to that extra s. 
Frank VerrillFrank Verrill
I don't have html experience so it took me a bit of time to get the ;syntax correct reading through the different threads.
The following passes the challenge:

Hope this helps.

The VF page:
<apex:page controller="NewCaseListController">
	<apex:form >
    
        <apex:pageBlock title="New Case List" id="cases_list">
        
        <apex:repeat value="{! newcases }" var="case">
        	<p><apex:outputLink value="/{! case.Id}">{!case.CaseNumber}</apex:outputLink></p>
        </apex:repeat>
      
    </apex:pageBlock>
    
    </apex:form>

</apex:page>

The controller:
public class NewCaseListController {
    public List<Case> getNewCases() {
        List<Case> newCaseList = Database.query('Select Id,CaseNumber ' + 
                                                'From Case ' + 
                                                'Where Status=\'New\''
                                               );
        return newCaseList;
    }
}
RadnipRadnip
Just saw this. FYI you don't need the form tags in your visualforce page as your not submitting any records. I can't get this challenge to work :(
InesGarciaInesGarcia
Alrighty,

After speding quite a bit of time on this myself.

1. The repeat component needs:Value, Var and ID. 
2. Filter on New to 'WHERE Status = \'New\' '

So thats is how would work and pass the badge:

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

}


​Tada!
Ben HeissBen Heiss
I have follow the steps that have been laid out in this thread. I continue to get this error message.

Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: unexpected token: Status

What is the logic for add the \'NEW\' ' for status instead some else like  ' Status = "NEW" ' ?

Help and Clarification welcomed
Deepak MahapatraDeepak Mahapatra
Hi Guys, 

Even I am facing the same issue as Benjamin is facing. Could someone please help ?

Thanks
Deepak
Fred DunawayFred Dunaway
I was having issue with the challenge not meet with errors complaining about the custom controller not working, even though a test case showed otherwise and the page rendered correctly.  Ines's soltuion did work for me.  Many thanks Ines for posting it.
Oladayo OlarindeOladayo Olarinde
Guys, i got the following code to work: VSF
<apex:page  controller="NewCaseListController">
    
   <apex:repeat value="{!NewCases}" var="case" id="case">
       <apex:outputLink value="{!case.id}"/><br/>
       
    
    </apex:repeat> 
</apex:page>

AND 

Apex class:

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

}
}
Steve ClarkeSteve Clarke
make the links open to the page:
 
<apex:outputLink value="{!urlfor($action.case.view,case.Id)}">{!case.caseNumber}</apex:outputLink>

 
Rich FiekowskyRich Fiekowsky
This works (the links open the Case records) if you code as Steve Clarke does,
<apex:outputLink value="{!urlfor($action.case.view,case.Id)}">{!case.caseNumber}</apex:outputLink>
however the Challenge fails.
Coding instead
<apex:outputLink value="{!case.Id)}">{!case.caseNumber}</apex:outputLink>
passes the Challenge, but, the links fail (on my system at this time); they display a page which only contains the message "The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. " Since a previous unit used the URLFOR($Action... technique in this situation, perhaps the challenge evaluation may be at fault here. 
Daniel RobertsDaniel Roberts
Hey everyone, quick question about binding on the <apex:repeat> and the binding "{!NewCases}". How does the naming work here? Can we make the binding whatever name we want, or is it whatever follows the "Get" i.e. GetBindingName()? 

 
RajasekharReddy KotellaRajasekharReddy Kotella
hi i tried this one and got no error
public class NewCaseListController  {
    public List<case> getNewCases(){
        list<case> c=[select id,casenumber from case where status='new'];
        return c;
    }
}


<apex:page controller="NewCaseListController"  >
  <apex:pageBlock title="New Case List" id="cases_list">            
    <apex:repeat Value="{!newcases}" var="case">     
        <apex:outputLink value="{/!case.id}"> ID:  {! case.id } </apex:outputLink>  <t></t>      
        <apex:outputLink value="{/! case.id}">Case Number:  {! case.CaseNumber }</apex:outputLink><br/>
    </apex:repeat>         
 </apex:pageBlock>
</apex:page>
Neel Shah 12Neel Shah 12

Hello All,

I have written the following code but it still gives me error. 

May i know the mistake i am doing and how can i rectify ?

Error: 
The outputLink component on the 'NewCaseList' page isn't binding to the ID of a case.

Code: 
VF Code: 
 

<apex:page controller="NewCaseListController">
  <apex:pageBlock title="New Case List" id="case_list" >
      <apex:pageBlockTable value="{!NewCases}" var="ct">
          
         <apex:column headervalue="Case Link"><apex:outputLink value="/{!ct.id}">{!ct.id}</apex:outputLink>
       </apex:column>
          <apex:column value="{!ct.CaseNumber}">  
          
          </apex:column>
          <apex:column value="{!ct.Status}"/> 
         
  <apex:repeat var="case" value="{!NewCases}">
    </apex:repeat>
          
          </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Controller:
public class NewCaseListController {
    List<Case> results = new List<case>(); 
    public List<Case> getNewCases()

     {
        results =[SELECT ID, CaseNumber, status FROM Case where status='New' LIMIT 10 ];

       return results;

    }
}

Output :
Output

Thanks in advance.