I have created a Custom Detail button on a Custom Object in salesforce classic. But now i am not able to see this button on lightning. I am not sure which LTX action should i create for my button.

As far i know custom javascript buttons are not supported in LTX but there must some way to implement this detail button in LTX.

{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/31.0/apex.js")} 
  var message = new sforce.SingleEmailMessage(); 
    message.targetObjectId = "0031I00000BmAhv"; 
    message.toAddresses = "{!Worker__c.Email__c}"; 
 message.templateId = "00X1I000000ZIpT"; 
 message.whatId = "{!Worker__c.Id}"; 
  var startDate = "{!Worker__c.Email_Start_Date__c}"; 
   var EndDate = "{!Worker__c.Email_End_Date__c}"; 
   var sDate = new Date(startDate); 
   var eDate = new Date(EndDate); 
    if(startDate == '' || EndDate == ''){ 
    alert("Please Enter Email Start Date & End Date !!"); 
     }else if(sDate > eDate){ 
     alert("End Date Must be higher than Start Date !!"); 
     }else{ 
     var result = sforce.connection.sendEmail([message]); 
     if(result[0].success == 'true') 
       { 
      var p = new sforce.SObject('Worker__c'); 
         p.id = "{!Worker__c.Id}"; 
       p.Email_Start_Date__c = null; 
      p.Email_End_Date__c = null; 
        result = sforce.connection.update([p]); 
      location.reload(true); 
       alert("Email Sent Successfully !!"); 
          } else 
           { 
      alert("Email Sending Failed"); 
    } 
       }

Sales force, however, is not allowing the use of JavaScript buttons in the Lightning Experience for security reasons.

So You can build a quick actions for lightning components.

or Replace java script button with url button

Please go through trailhead:

https://trailhead.salesforce.com/en/modules/lex_javascript_button_migration

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.