You need to sign in to do that
Don't have an account?
fiona gentry
How Apex can be used to Send Case to Lightning cmp
Hi,
i need to send current case to lightning component and wrote below apex but seems i am not able to send current case record id to lightning component,any solution
controller file
Problem is alert shows "undefined" in browser that means something is wrong,any suggestions
Fiona
i need to send current case to lightning component and wrote below apex but seems i am not able to send current case record id to lightning component,any solution
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]; } }cmp file
<aura:attribute name="record" type="case[]"/>
controller file
var action = component.get("c.getCaseFromId"); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { var navEvent = $A.get("e.force:navigateToSObject"); alert("hello there!"+ component.get("v.record",response.getReturnValue())); navEvent.setParams({ "recordId": component.get("v.record",response.getReturnValue()) }); navEvent.fire();
Problem is alert shows "undefined" in browser that means something is wrong,any suggestions
Fiona
When we use Apex Class in lightning it must be declared as @AuraEnabled annotation
@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];
}
}