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
Mitchell McLaughlin 10Mitchell McLaughlin 10 

Invoking Apex Class from Custom Buttons - Lightning/Classic

HI All,

The salesforce org which I'm working on right now is currently using Classic. They want a custom button to invoke an apex class - which sits on the page layout.

I believe the best practice is to create a custom button which directs to a  VisualForce page, behind the scenes, to invoke an apex class. Is this still the best way to go, if the client is going to move to lightning soon?

Thanks
Amit Chaudhary 8Amit Chaudhary 8
Well you can use same apex class for lightning for business logic. But For lightning you need to change your logic for redirect in future.
Raj VakatiRaj Vakati
This is what my suggestion  Mitchell  .. 

As you have a plans to migrate to Lightning so define the lightning component and call the Lightning component from the VF page by using lightning out. 

In case if you move the lightning in the feature you have already lightning component which you can call it on lightning actions.