+ Start a Discussion
AJAYAJAY 

Create a Visualforce page displaying new cases in trail head (challenge task)

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.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [types__c, model__c]: [types__c, model__c]


This is the error i am getting when trying to solve the task in custom controllers,but i am able to perform the task in my friend's org.Can anyone find out the problem out there?

These are the codes i used for apex class and visual force pages.

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

 
swati_sehrawatswati_sehrawat
You need to check if model__c is required on case object at page layout level or at field level.
Naveen DhanarajNaveen Dhanaraj
Hi AJAY KONATHALA,
Try this,
<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>
 
public class NewCaseListController {

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

}

 
swati_sehrawatswati_sehrawat
I don't think it is query issue, if we look at the error there is a "REQUIRED_FIELD_MISSING" issue for field model__c
Kapavari VenkatramanaKapavari Venkatramana
Ajay Its Working. Code is Correct Only.