Ask Search:
Ed LawrenceEd Lawrence 

Custom Button not working in Lightning

Hu guys & gals,

I have an issue with a button that creates a new Opportunity (renewal) on a Custom Object we call 'Support Contracts'. The button is used when the support contract is coming up for renewal so it creates a new record. This isn't supported in Lightning obvioulsy so i used the Lightning Configuration Converter to replicate and add the button into Lightning. 

When i press the button however i get the ERROR - A Component Error Has Occurred!
Original OnClick JavaScript:

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 

if (confirm("You are about to create a NEW opportunity to renew this contract. Click OK to confirm.")) { 
var result = sforce.apex.execute('SupportContractRenewal' , 'renewOpportunity', {sContractId:'{!Support_Contracts__c.Id}'}); 
if(result.length==2) { 
alert(result[1]); 
}else{ 
window.open("/"+result[0],"myWindow"); 

}

Any help on this would be greatly appreciated! :)
Best Answer chosen by Ed Lawrence
Amit SinghAmit Singh
Hi Ed,

JavaScript Button does not work in Lightning Component. You have to Use Lightning Component or Other Alternative.

Refer below link
https://trailhead.salesforce.com/en/content/learn/modules/lex_javascript_button_migration

All Answers

Amit SinghAmit Singh
Hi Ed,

JavaScript Button does not work in Lightning Component. You have to Use Lightning Component or Other Alternative.

Refer below link
https://trailhead.salesforce.com/en/content/learn/modules/lex_javascript_button_migration
This was selected as the best answer
Ed LawrenceEd Lawrence
Thanks Amit, can't really find a solution for this particular query in here however.
Amit SinghAmit Singh
Hi Ed,

Is there something where you got stuck.