My Lead Convert button overrides standard and uses a VF page. When switching to Lightning, this button causes a new tab to open endlessly until I close completely out of the browser. Am I able to make this stop firing and work properly in Lightning? This does not happen in Classic.

Here is my code:

<!-- Use this page to override the standard Lead Convert action. This page will
     check a checkbox field on the Lead record; checking that checkbox will
     cause the Lead to not meet the workflow rule's criteria, which will remove
     the Lead from the workflow queue, and allow it to be converted. -->
<apex:page standardController="Lead" > 

<apex:form >
    <div style="visibility:hidden;">
        <apex:inputField value="{!Lead.Cancel_Workflow__c}" id="cancelWorkflow" style="visibility:hidden; "/>

<apex:actionFunction name="quickSave" action="{!quickSave}" oncomplete="standardConvert();"/>
    <apex:actionFunction name="standardConvert"
      action="{!URLFOR($Action.Lead.Convert, lead.id, [retURL=$CurrentPage.parameters.retURL], true)}" />

<script language="JavaScript">

    // When the page finishes loading, do the default window.onload action,
    // then call our fixLead() function.
    var previousOnload = window.onload;
    window.onload = function() {
        if (previousOnload) previousOnload();

    // Edit the Lead to set the Cancel Workflow flag.
    // When quickSave() finishes, it will redirect to the default Convert action.
    function fixLead() {
        var elemCancelWorkflow = document.getElementById('{!$Component.cancelWorkflow}');
        elemCancelWorkflow.checked = true;

  • I do not know if this is the cause of your problem, but there are two things that could be relevant. 1. The lead conversion process in Lightning is different than in Classic. 2. Code in Lightning runs under a different SessionID than it does under Visualforce so you may need to get it and the userId reference to pass to the component for permission & security checks. Either or both of these could be contributing to the problem you are having. – crmprogdev Oct 14 '18 at 14:34

Once the "standardConvert" Action-Function is executed, the page is reloading and thus window.onload function is called again and all the process is going into the loop. A simple solution here would be to just add oncomplete="return false;" to the "standardConvert" Action-Function and it will open the standard lead convert form just once.

Select this as the best answer if it resolves your issue.

  • Are you thinking that I should replace the current oncomplete="standardConvert();" or add it after the URLFOR? <apex:actionFunction name="quickSave" action="{!quickSave}" oncomplete="standardConvert();"/> <apex:actionFunction name="standardConvert" action="{!URLFOR($Action.Lead.Convert, lead.id, [retURL=$CurrentPage.parameters.retURL], true)}" /> – Laura Babb Oct 15 '18 at 16:14
  • I added it to after URLFOR and it worked perfectly! Thanks! – Laura Babb Oct 15 '18 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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