[SalesForce] Receiving “Profile does not have access to” in the flow when calling invocable apex class

I have a flow that calls an invocable action from apex class. It accepts a list of required parameters and the flow has been working for the last 2 years. And then something happened and the flow started giving a permission error (see below). Though the flow wasn't changed since then and permissions for the profiles weren't changed as well. All profiles have access to the apex class and Manage Flow AND View All Data permissions. A couple of days ago we deployed critical updates in our org but don't think anything would result in this behavior.

enter image description here

And here's an invocable class that gives a permission error. Tried to use without sharing and global attributes and didn't work any.

public without sharing class  AddTaskAsEmailActivity {
    
    public class InvocableVariables {
        @InvocableVariable(required=true) 
        public String emailTemplateDeveloperName;

        @InvocableVariable(required=true) 
        public Id caseId;

        @InvocableVariable(required=true)
        public String toAddress;

        @InvocableVariable(required=true)
        public String fromAddress;
    }

    @InvocableMethod(Label='Create Email Message Activity' Description='Creates email message as activity and attaches to case')
    public static void init(InvocableVariables[] variables) {
        for (InvocableVariables params : variables) {
            createTaskAsActivity(params);
        }
    }

    public static void createTaskAsActivity(InvocableVariables params) {....}

Does anyone have any ideas what could be the problem?

Best Answer

Open profile setup then 'Apex Class Access' and make sure 'AddTaskAsEmailActivity' class is in the allowed list.

Related Topic