I've been dabbling around Lightning Components (Aura). I decided to use Aura so I can display may Lightning Web Component (LWC) in a pop-up window (or modal) through the click of a Custom Quick Action. However, I keep getting an error.

Basically, all I'm trying to accomplish with Aura is to:

  1. Fetch the Stage__c field by calling an Apex method.
  2. Check if that Stage__c's field value is equal or not equal to "Closed".
  3. Display a toast message and close the component if Stage__c == "Closed", in succession.

I've written a simple code to do this but I can't seem to move forward and call the Apex correctly as I'm always receiving this error:

enter image description here

So, I checked my Apex method to make sure it has @AuraEnabled annotation, but to no avail.

Here's what I have:


<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
    <aura:attribute name="recordId" type="Id" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 
    <c:editProduct recordId="{!v.recordId}" onclose="{!c.closeQA}"/>

Controller JS

({ doInit : function(component, event, helper){

Helper JS

getOppty : function(component, event, helper) {
    var action = component.get("c.getOpptyCurrency");
        opptyId: component.get("v.recordId")
    action.setCallback(this, function(a){
        var state = a.getState();
        var returnVal = a.getReturnValue();
        console.log('Return Value :', returnVal);

        if(state == "SUCCESS"){
            for(i=0; i < returnVal.length; i++){
                var stage = returnVal[i];
            console.log("Failed with state: " + state);

    console.log('Stage :', stage.Stage__c);
    if(stage.Stage__c === "Closed"){
        this.closeQA(component, event, helper);
        this.showError(component, event, helper);

showError : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
            title : 'Error',
            message:'This is an error message',
            duration:' 5000',
            key: 'info_alt',
            type: 'error',
            mode: 'dismissible'

closeQA : function(component, event, helper) {


public static Opportunity__c getOpptyCurrency(string opptyId){
        Opportunity__c oppty = [SELECT Id, Stage__c
                                FROM Opportunity__c
                                WHERE Id =: opptyId LIMIT 1];
        return oppty;

Can anyone help point me in the right direction? What am I doing wrong exactly in this case

  • One side note on the apex method parameter, you should use the Id type rather than a String when you're working with a record id to easily prevent things such as SOQL injection. getOpptyCurrency(Id opptyId)
    – Mark Pond
    Commented Jun 1, 2020 at 15:42

1 Answer 1


You need to define the controller for the Aura Component.

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" controller="myApexClass">

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .