I have built a class that calls a system external to Salesforce for checking customer's data. The service is an electronic VAT check provided by the state in the form of a very simple API.

I want to be able to call that class both via Javascript remoting (using @remoteAction annotation), from a Lightning Component (using @auraneabled annotation) and from a Flow (using @invocableMethod annotation).

The use cases are: call the eVAT service both from the client side (when the customer first inputs its data on registration), and from the back-end side (when a financial manager wants to check that VAT data is correct for existing customers)

Am I forced to design a class with two almost identical methods (one with @remote and one with @invocable) or are there better strategies / workarounds?

Thanks in advance for the answer coming from your hive brain, fellow SF folks.

1 Answer 1


Looks like you can't stack @InvocableMethod annotations.

Other annotations can’t be used with the InvocableMethod annotation.

Reference here

However, what I'd normally do is make these methods wrappers, so you'd have one method like this:

public static List<String> getAccountNameList(List<ID> ids) {
  return getAccountNamesInternal(ids);

public static List<String> getAccountNames(List<ID> ids) {
  return getAccountNamesInternal(ids);

private static List<String> getAccountNamesInternal(List<ID> ids) {
  //do common stuff here

This will at least keep these extra methods very small and easily maintainable. Notice you CAN stack the other annotations, saving you an extra method.

  • Thanks Caspar, that's the design I'll go for then :) Dec 10, 2019 at 13:12

You must log in to answer this question.

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