I'm working on one LWC and facing issue while passing parameters to an apex method which I am calling imperatively on selection of a record in datatable. I'm able to get selected recordid in JS function and call js function but I always get error when parameter is passed. Imperative calling seems to be working fine when no param is passed. Code posted below:

Import: import executeAction from '@salesforce/apex/DSE_SetAccountAdmin_CtrlX.executeAction';


buttonClicked(event) {
    executeAction(labelToActionMap.get(event.target.label), this.selectedContact.Id)
        .then(result => {
            console.log('TCL: dseContactManagementForSelectedAccountLwc -> buttonClicked -> result', result)

        .catch(error => {
            console.log('TCL: dseContactManagementForSelectedAccountLwc -> buttonClicked -> error', error)


Apex method declaration: @AuraEnabled public static Boolean executeAction(String actionName, String selectedContactId){

I keep getting below error in console.

Error in console printed in buttonClicke function

I believe I'm missing some syntax here. Do I need to pass params as a map object as shown in error?


Yes, it's supposed to be an object:

executeAction({ actionName: labelToActionMap.get(event.target.label), 
                selectedContactId: this.selectedContact.Id })

The object key values should match the Apex parameter names.

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.