+ Start a Discussion
Michael Agres 2Michael Agres 2 

Creating & Using Custom Controllers Trailhead Challenge -- error message

When I preview and try to check the challeng, I get this:

line 1:47 no viable alternative at character '"' 
An unexpected error has occurred. Your development organization has been notified.

___

Here's my vf page:
 
<apex:page controller="NewCaseListController">
    
    <ul>
        <apex:pageBlock title="New Cases" id = "cases">
        	<apex:repeat value = "{!newCases}" var = "case">
            	<li>
                    <apex:outputText value = "{!case.id}"/>
                        <br/>
                    <apex:outputLink value = "/{!case.id}">Click here!</apex:outputLink>
                </li>
            </apex:repeat>
        
        </apex:pageBlock>
        
    </ul>
    	
    
</apex:page>

... and here's my controller:
 
public class NewCaseListController {
    // stuff goes here
    
    public List<Case> getNewCases() {
        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber FROM Case WHERE Status = "New" ');
        
        return results;
        
    }
}

Not sure where on line 1 I'm drawing the blank (invisible) space/character.

Anyone else run into this?
Best Answer chosen by Michael Agres 2
Amit Singh 1Amit Singh 1
use below code.
public class NewCaseListController {
    // stuff goes here
    
    public List<Case> getNewCases() {
        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber FROM Case WHERE Status = \'New\' ');
        
        return results;
        
    }
}

 

All Answers

Amit Singh 1Amit Singh 1
use below code.
public class NewCaseListController {
    // stuff goes here
    
    public List<Case> getNewCases() {
        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber FROM Case WHERE Status = \'New\' ');
        
        return results;
        
    }
}

 
This was selected as the best answer
NagendraNagendra (Salesforce Developers) 
Hi Michael,

After spending some time on the above challenge I got the below code to work.

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

So that's 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;
    }

}
Hope this helps.

Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

 
atul patil 7atul patil 7
Hello Michael,
        Refer this Controller code
 
public class NewCaseListController {
    // stuff goes here
    
    public List<Case> getNewCases() {
        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber FROM Case WHERE Status = \'New \'');
        
        return results;
        
    }
}

Thanks
Atul Patil
Salesforce Developer