+ Start a Discussion
Raj R.Raj R. 

How to get apex class to work in Lightning and Classic?

Hi,

We had an apex class that originally worked on Salesforce classic. Now we have added "@AuraEnabled" so that it can work with lightning. However we are finding that the apex class is no longer being called as expected while in classic.

Is it possible to write one apex class (with 1 method) to work on both classic and lightning? I would prefer not to write the same method twice, one for classic and one for lightning.
Best Answer chosen by Raj R.
Akhil AnilAkhil Anil
Hello,

If you want to refer the same method in a VF page and a lightning component, then that's just NOT possible as of today. You will have to write individual methods for each of them. AuraEnabled methods cannot work with classic VF pages.

All Answers

Akhil AnilAkhil Anil
Hello,

If you want to refer the same method in a VF page and a lightning component, then that's just NOT possible as of today. You will have to write individual methods for each of them. AuraEnabled methods cannot work with classic VF pages.
This was selected as the best answer
Raj R.Raj R.
Hi Akhil,

Well it is not just limited to VF pages. We have triggers that run on create, update, or delete events that call apex classes when some criteria is met. We need the ability to have our current triggers call a single apex class that will work in both Lightning and Classic.

Do you know how (if possible) we would be able to have a trigger call 1 method that works in both Lightning and Classic?