I am trying to get case record Id using lightning button but my controller is not moving forward from this line -component.get("v.recordId") I don't know what is wrong.
Please help:
This my component
<aura:component controller="EmailSendController" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global">
<lightning:button label="Send Notification" title="Send Notification" onclick="{!c.sendMail}"/>
This is my controller
({
sendMail: function(component, event, helper) {
console.log("Button Clicked--");
var caseID = component.get("v.recordId");
Console.log("CaseID--"+ component.get("v.recordId") );
var action = component.get("c.sendMailMethod");
action.setParams({
"caseId" : caseID
});
action.setCallback(this, function(response) {
var state = response.getState();
Console.log("Response"+response.getState());
if (state === "SUCCESS") {
//var storeResponse = response.getReturnValue();
}
});
$A.enqueueAction(action);
},
})
JavaScript is case-sensitive. 2nd Console
should be lowercase, I suspect it throws an error about undefined object.
You can use your browsers JS console (in Chrome Ctrl+Shift+J) to inspect such errors. It also helps to go to Setup -> Debug Mode and add your user in there. SF will get bit slower but you'll see more human-readable code and errors instead of optimised, minified mess.
If it still throws errors - use console to check what error exactly and edit your question?
P.S. change it in callback handler too