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
Raymond AireyRaymond Airey 

Converting Javascript button for Lighting

Hi All,

We currently use the classic version of Salesforce but are looking into moving to the Lighting platform. One of the things that is holding us back in that we currently have a javascript button on the Opportunities page which when clicked, creates an EDI file in the background that is sent for processing in an external system.

Below is the code currently used in the Javascript button:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} 
var result = sforce.apex.execute("orderOutput","generate", {genericId:"{!Opportunity.Id}"}); 
window.alert(result ); 
window.location.reload(true);
Does anyone have any ideas what or how I could convert this into something compatible with Lightning?

Appreciate any help or guidance,

Raymond
SandhyaSandhya (Salesforce Developers) 
Hi Raymond Airey,

You cannot use javascript buttons in Lighting,instead you need to create button component and make use of it.

https://success.salesforce.com/ideaView?id=08730000000cGX8AAM

 Please refer below links to get more information on creating button component.

https://trailhead.salesforce.com//en/project/slds-lightning-components-workshop/slds-lc-5
 
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ui_button.htm

 Hope this helps you!

Thanks and Regards
Sandhya