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
Richard ValenciaRichard Valencia 

Help with Javascript code for custom button in Lighting

I'm currently moving my team over to lighting and I'm needing help with converting a custom Java button that can not be converted by the Salesforce Converter tool. 

My custom button lives in a Custom object and is placed on the Related list. The buttom currently allows users to make the checkbox = ture and and then select the "Complete" button(JS) which will then mark all the selected records as "Completed" this is currenlty working in Classic but not avliable in lighting. 
User-added imageJava code for classic button: 

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")};
var records1 = {!GETRECORDIDS($ObjectType.Milestone1_Task__c)}; 
var newRecords = [];
var taskRec = sforce.connection.query('select id,name,Task_Stage__c from Milestone1_Task__c where id in (\'' + records1.join('\',\'') + '\')' );

var tasks = taskRec.getArray("records"); 
var arrayLength = tasks.length;
if(records1==null || records1=='') { 
  alert('No records selected'); 

else{
    for(var i=0;i<arrayLength;i++){
       var tsk = new sforce.SObject("Milestone1_Task__c");
       tsk.Id = tasks[i].Id;
       tsk.Task_Stage__c = 'Completed';
       newRecords.push(tsk);
    }
    
    result = sforce.connection.update(newRecords); 
        window.location.reload();
}

User-added image
AnudeepAnudeep (Salesforce Developers) 
Hi Richard, 

I recommend reviewing this blog to get started

Also, Is the lightning experience configuration converter tool not detecting the javascript button?
Richard ValenciaRichard Valencia
@Anudeep
Configuration Converter tool output: 
User-added image