+ Start a Discussion
Rajasree JayarajRajasree Jayaraj 

Replace Javascript button | A URL button which validates a field prior to calling a URL

Hello,

I am figuring out ways to replace our javascript buttons to lightning compatible one. We have quite a lot of javascript button one of which is "Send with Docusign" that lets a user send a contract using Docusign. I'm calling the right docusign template using this custom button & passes some parameters like recipient email. I have a part of code that validates if the contract is approved by the leads before it could be sent to client with docusign. Something like this:

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

var contrObj = new sforce.SObject("Contract"); 
contrObj.id = "{!Contract.Id}"; 
var ContrStatus="{!Contract.Contract_Status__c}"; 
var profile ="{!User.Profile}"; 

if(ContrStatus!='Approved') 

alert("The contract should be approved before sending for signature"); 

else{ 
window.location.href = '/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Contract.Id}&CRL=Email~{!Contract.Business_Contact_Email_Formula__c};FirstName~{!Contract.Business_Contact_First_Name__c};LastName~{!Contract.Business_Contact_Last_Name__c},.....................'; 
}

Now, I need to replace this javascript button with components that are lightning compatible (since we are plannign to switch to Lightning) . I'd like to know what are the possible options?

Thank you very much in advance!

JSingh9JSingh9
Hi Rajasree, 

This should help you https://trailhead.salesforce.com/en/modules/lex_javascript_button_migration

Thanks,
JS
Hey SandboxHey Sandbox
Hi Rajasree,

Button (with JavaScript) is not available for Lightning use. You can not override this button for Lightning use. It is for Classic use only.
You can see this Salesforce documentation reginding this:
https://help.salesforce.com/articleView?id=links_customize_override.htm&type=0&language=en_US&release=208.13

For this issue, You have to create a Lightning component to develop this functionality. 
Refer this links for more: 
http://bobbuzzard.blogspot.in/2016/11/lightning-component-actions-with.html
http://blog.sujeshram.com/2016/12/how-to-get-most-out-of-lightning.html
https://webkul.com/blog/how-to-create-a-custom-button-on-record-page-in-lightning-experience/

I think above all reference links will help you on this issue.

Thanks,
Prashant