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
Ebrahim AbdulsattarEbrahim Abdulsattar 

Lighting component workaround to replace Javascript button

Hello and thank you for your assistance in advance! I have a simple Javascript button that isn't working in Lighting, so I would apprecaite any help I get to make it work in my org. 
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 

var result = sforce.apex.execute("WebServices_Batch","ApproveAllTransactions",{batchId: '{!Batch__c.Id}' }); 

if(result == 'SUCCESS'){ 

window.location.reload(); 
} 
else if(result == 'BatchAmountMismatch'){ 
alert('There is still a balance remaining for this batch'); 
} 
else{ 
alert('There was an error updating. Please contact your administrator.'); 

}

 
Raj VakatiRaj Vakati
You need to replace the Javascript button with quick action  .. use the Lightning Experience Configuration Converter that will generate the code for you 


https://developer.salesforce.com/blogs/2018/06/convert-javascript-buttons-to-lightning-friendly-alternatives-with-the-lightning-experience-configuration-converter.html



https://admin.salesforce.com/lightning-experience-configuration-converter

https://trailhead.salesforce.com/content/learn/modules/lex_javascript_button_migration/lex_javascript_button_migration_intro

https://developer.salesforce.com/forums/?id=9060G000000MVV9QAO

https://www.ankittaneja.net/replacing-onclick-javascript-button-with-lightning-component/
http://astreait.com/Custom_Button_OnClick_JavaScript_through_Lightning_Components/

 
Pawan Kumar 32Pawan Kumar 32
Javascript buttons are not supported in salesforce lightning experience. You need to create either lightning custom component or Lighting Quick action. You can visit below link for your reference:

https://sompaul2012.wordpress.com/2018/04/05/lightning-action-as-a-replacement-of-javascript-button/
https://help.salesforce.com/articleView?id=lcc_javascript_buttons_overview.htm&type=5