function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CooldayCoolday 

Can we use @auraenabled and @invokable at the same time in Apex Class?

We have a requirement for which I created a LWC component and Flow for the same Apex class. Can we use @Auraenabled and @Invokable at the same time for the method in Apex class.

Thanks 
Best Answer chosen by Coolday
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Yes, you can use multiple annotations on a method or class; they are written separated by any whitepsace. But there are some exceptions for it like 
You can not add both @future and @InvocableMethod to a single method.

Coming to your question as per the documentation
Other annotations can’t be used with the InvocableMethod annotation.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Yes, you can use multiple annotations on a method or class; they are written separated by any whitepsace. But there are some exceptions for it like 
You can not add both @future and @InvocableMethod to a single method.

Coming to your question as per the documentation
Other annotations can’t be used with the InvocableMethod annotation.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
This was selected as the best answer
CooldayCoolday
In the method I am accepting ID as a parameter and not the List of Ids. So, if I am using both @invocableMethod and @auraenabled then it is resulting in error.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Yes as I highlited above it may not be possible to add another annotation with InvocableMethod.

Thanks,