I am trying to convert the Salesforce Classic Javascript button to Lightning Experience. The button has a custom URL. I don't know how to replace the custom URL in lightning. The button uses the connection query and some alert as well.

Please let me know how to convert the Javascript button to Lightning Experience.

Below is the Javascript button code:

var result = sforce.connection.query("Select id,Name,Geocoding_Status__c from Account where id = '{!Account.Id}'");
var accountRecords = result.getArray("records");
var arrayLength = accountRecords.length;
    for(var i=0;i<arrayLength;i++){
            var r = confirm('This will retrieve data from our data partner, Core Logic. Press OK to confirm.');
                var LeinCheck = sforce.apex.execute('LeinCheckCoreLogicIntegration','CoreLogicCallout',{id:'{!Account.Id}',conID:'{!Contact.Id}'});
                sforce.debug.trace = true;

            alert('Please correct the Account address for this Contact. Lien Check requires a valid address.');

Thank You


1 Answer 1


Use the standard converter: HERE

If that doesn't work, you should create a lightning component that does the same functionality --> Seems like a query for a single account record and a callout using an apex method. You can later expose your lightning component as a button and voila! Good luck!

  • I have started writing the lightning component for the JS button. I have called the @AuraEnabled method which is returning me the query result. But in JS button I have to check the "accountRecords[i].Geocoding_Status__c=='OK'" . But in helper, I am not able to check that.
    – Naman Jain
    Commented Aug 14, 2019 at 15:47
  • You should be able to check in the js controller, js helper and the apex controller for that condition. What issue are you seeing? Can you post the code here for further inspection? Commented Aug 14, 2019 at 16:55
  • Now I reached till if condition Geocoding_Status__c=='OK'. But don't know how to convert confirm in lightning controller or helper. Do you have any idea how to replace confirm().
    – Naman Jain
    Commented Aug 14, 2019 at 19:12
  • The easiest way is to add the confirm to the onclick of the command button. The action will only execute if they select "OK". biswajeetsamal.com/blog/add-a-confirm-dialog-to-a-command-button/ Commented Aug 14, 2019 at 19:22
  • But the link shows for VF page <apex:commandButton reRender="frm" value="Remove" action="{!remove}" onclick="if(!confirm('Do you want to remove?')){return false};" title="Remove"/>. But how to do in lightning controller or helper
    – Naman Jain
    Commented Aug 14, 2019 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .