0

can i use multiple annotations in single apex class; like i have the scenario of calling apex class from process builder which is having future method,suppose i am using setup objects and non-setup objects for that i have to use @future annotation for not getting dml exception error and if i want to call same class from process builder for that i need to use @invokable method. how can i achieve this scenario

1 Answer 1

5

You can not add both @future and @InvocableMethod to a single method.

However, given your scenario, you can delegate the task of working with a setup method to another method with @future annotation.

public with sharing class MyClass {
     @InvocableMethod(label='Get Account Names' description='Returns the list of account names corresponding to the specified account IDs.' category='Account')  
     public static void myMethod(List<ID> ids) {
         futureCall();
     }

    @future
    public static void futureCall() {
        //long-running Apex code
    }
}

You must log in to answer this question.

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