You need to sign in to do that
Don't have an account?
Replace Javascrip Button
I'm looking for the simplest way to proceed.
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
We have a Javascript button in Salesforce classic. It is on a custom object called Addresses. We have customers with multiple addresses they move back and forth to and from, so we list the addresses in this object. There is a button on the records that they users push to populate the addresse in that record as the current address in the account.
Here is the JS button code.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}
var addr = "{!WV_Addresses__c.Id}";
var id = sforce.apex.execute("WV_AddressService","CopySingleAddress", {AddressID:addr});
window.alert("Address has been copied." );
This calls a Webservice program...
global class WV_AddressService {
WebService static void CopySingleAddress(ID AddressID){
WV_Addresses__c addr = [Select w.Worker_Profile__c, w.Type__c, w.SystemModstamp, w.Street__c, w.State__c, w.Postal_Code__c, w.OwnerId, w.Name, w.LastModifiedDate, w.LastModifiedById, w.IsDeleted, w.Id, w.Full_Address__c, w.Current__c, w.CreatedDate, w.CreatedById, w.Country__c, w.City__c, w.Active_On_Date__c, w.Mobile_Phone__c From WV_Addresses__c w WHERE Id = : AddressID];
WV_AddressController.CopyToAccount(addr);
}
}
Which calls the WV_AddressController.
Obviously the button does not work in Lightning, but the rest of the code works wonderfully and is a big timesaver for our users.All I ned to do is to replace the button that calls the Webservice with the 2 lines of script that the javascript button is currently calling. What is the easiest way to get than done?
Thanks!
You need to create a quick action and call the webservice from the quickaction. More details in link below:
https://www.mstsolutions.com/technical/launching-lightning-component-as-quick-action/
All Answers
You need to create a quick action and call the webservice from the quickaction. More details in link below:
https://www.mstsolutions.com/technical/launching-lightning-component-as-quick-action/
Thank you. That is what I needed to know!