0

Have anybody any idea why in the inspector we have empty action string

cmp

<aura:component description="CountOpp"
                controller="ControllerConfigClass"
                implements = "force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction"
                access="global">


    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />


</aura:component>

controller

({

    doInit : function (cmp, event, helper) {
        helper.doInitAction(cmp, event);
    }
});

helper

({
    doInitAction : function (cmp, event) {

        var action = cmp.get("c.check");
        console.log("action: ", action);


    }
});

controller Apex

public with sharing class ControllerConfigClass {

    @AuraEnabled
    public static String check(){
        String isFeatureEnabled = 'test isFeatureEnabled';
        System.debug('isFeatureEnabled ' + isFeatureEnabled);
        return isFeatureEnabled;
    }
}

Thx for any idea

1
  • Note: triple backticks need to be on a line by themselves to format correclty. – David Reed Nov 23 '20 at 18:38
0

So in the helper method the cmp.get("c.check") returns a reference to an action available in the controller. In this case, it returns a remote method call to our Apex controller.

after this line, you need to add the below lines so that your remote function is executed and to get the values you need to use getReturnValue to print the response or to execute your business logic.

I would suggest you have a look at this trailhead module which has a line by line explanation.

action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === 'SUCCESS') {
                var vac= response.getReturnValue();
                console.log(vac);
            } 
            else {
                console.log(state);
            }
            
        });
        $A.enqueueAction(action);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.