0

I am trying to access the variables sent from the Process Builder within the apex class. It says the variable accountParamter does not exist, which confused me because I declare it in the parameters of the invocable method.

public class ProcessHandlerShowAccounts {
    public class AccountParameter{
        @InvocableVariable(required=true)
        public Id accountId;
        @InvocableVariable(required=true)
        public String name;
    }
    @InvocableMethod(label='handleNewAccounts' description='Display the results from the Process Builder')
    public static void handleNewAccounts(AccountParameter [] accountParameters) {
        //Variable AccountParamters does not exist
        System.debug('The value for Account Id is: '+ accountParamters[0].accountId);
        System.debug('The value for  name is: '+ accountParamters[0].name);


    }
}

1 Answer 1

2

You have the typo in your parameter at line 5. You should replace accountParamters with accountParameters

public class ProcessHandlerShowAccounts {
    public class AccountParameter{
        @InvocableVariable(required=true)
        public Id accountId;
        @InvocableVariable(required=true)
        public String name;
    }
    @InvocableMethod(label='handleNewAccounts' description='Display the results from the Process Builder')
    public static void handleNewAccounts(AccountParameter [] accountParameters) {
        //Variable AccountParamters does not exist
        System.debug('The value for Account Id is: '+ accountParameters[0].accountId); //here you have typo
        System.debug('The value for  name is: '+ accountParameters[0].name);  //here you have typo


    }
}

You must log in to answer this question.

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