how to pass parameter to apex method which is called imperatively from lightning web component

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(, 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(, 
                selectedContactId: this.selectedContact.Id })

The object key values should match the Apex parameter names.

Source : Link , Question Author : Ashish Sharma , Answer Author : sfdcfox

Leave a Comment