0

I have a custom button to remove a lead from workflow in order to be converted. This button then redirects to the standard lead convert page. I have created a custom convert page and I replaced the oncomplete action that sent it to the standard page with my custom page. This button is still directing to the standard page though. Am I missing another step here?

    <!-- 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; "/>
    </div>

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

<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();
        fixLead();
    }

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

</script>
</apex:form>
</apex:page>
  • You say the button "redirects to the standard lead convert page", but then you say you have created a custom convert page. Why are you redirecting to the standard page then? And when you say you've "replaced the oncomplete action", do you mean you've overridden the Lead Convert action in Setup > Leads > Buttons? – David Cheng Mar 18 at 1:04
  • Yes, the button is overridden and what I'm showing above (oncomplete="leadConvertPage();) should send to my custom lead convert page, but it is not. The custom button cancels the workflow so that the lead can be converted, so within that VF is where I direct it to the convert page. It was directing to the standard page and I'm wanting to change that. – Laura Babb Mar 18 at 12:28
0

URLFOR was still directing to the standard convert page.

Change this:

action="{!URLFOR($Action.Lead.Convert, lead.id, [retURL=$CurrentPage.parameters.retURL], true)}" oncomplete="return false;"/>

To this:

action="{!URLFOR($Action.Lead.Convert_Lead, lead.id, [retURL=$CurrentPage.parameters.retURL], true)}" oncomplete="return false;"/>

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.