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
anthony thomas 9anthony thomas 9 

The component is not using the 'DisplayCaseController' Apex controller

Not sure why i keep getting this error on this challenge.
component:
<aura:component controller="DisplayCaseController">
    <aura:attribute name="record" type="Case"/>
    <ui:button label="Get Case" press="{!c.getcase}"/>
        <p>{!v.record.Status}</p>
        <p>{!v.record.Subject}</p>
        <p>{!v.record.Description}</p>
</aura:component>

controller:
({
    getcase : function(component, record, callback) {
         var action = component.get("c.getCaseFromId");
          action.setParams({
          "caseID": record.id
      })
          action.setCallback(this,function(action){
             if (action.getState() === "SUCCESS") {
                component.set("v.record", action.getReturnValue());
            }
      });
      $A.enqueueAction(action);
    }
 
})
Apex:
public class DisplayCaseControler {

    @AuraEnabled
    public static Case getCaseFromId(Id caseID) { 
        if(caseID == null) { 
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1]; 
        }
       
        List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];
       
        if(cases.size() == 0) { 
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1]; 
        } else { 
            return cases[0]; 
        } 
    }  

}
William TranWilliam Tran
Change this:
 
public class DisplayCaseControler {

to this:
 
public class DisplayCaseController {

that is using 2 els.

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks
anthony thomas 9anthony thomas 9
@William Tran i tried that also and go the same erro then too. Not sure why i cannot get this thing cleared baffling to me right now. I have tried several other codes that people say worked and i still get this error.
KaceyKacey
If you have already updated your controller name and component reference to use the DisplayCaseController, you can load the case data by having the compont load it during initialization like:
 <aura:handler name="init" value="{!this}" action="{call your client side controller function here}"/>