We have JavaScript buttons that follow this pattern:
{!REQUIRESCRIPT('/soap/ajax/39.0/connection.js')}
{!REQUIRESCRIPT('/soap/ajax/39.0/apex.js')}
var ok = confirm('Create the Interest Adjustment?');
if (ok) {
var result = sforce.apex.execute(
'InterestRulesActions',
'addInterestToPayment',
{paymentId: '{!Payment__c.Id}'}
);
if ('success' == result) {
// See the changes
window.location.reload();
} else {
// See the error message
alert(result);
}
}
calling server methods of this nature:
global class InterestRulesActions {
webservice static String addInterestToPayment(Id paymentId) {
...
}
}
Such buttons are no longer rendered in Lightning Experience and so require rework if "Lightning Ready" status is to be maintained.
A Lightning Action that invokes a Lightning Component appears to be the way to go. Is the best (and maybe the only) way to directly re-use the server-side code to add @AuraEnabled
to each method so it can be easily called from the Lightning Component:
global class InterestRulesActions {
@AuraEnabled
webservice static String addInterestToPayment(Id paymentId) {
...
}
}
This compiles; does it work?
webservice
method. Though I'm now thinking of having a single generic component that dispatches to the the relevant piece of existing code so that is now a moot point.