You need to sign in to do that
Don't have an account?
anthony 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];
}
}
}
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];
}
}
}
to this:
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
<aura:handler name="init" value="{!this}" action="{call your client side controller function here}"/>