1

I have created a custom conversion process that uses Visualforce. There is a custom button on the Lead page for conversion. I want that same button on Campaign Members that need to be converted, but that button is not there and when I tried to create a custom button connected to the Lead Convert VF page, no options for VF show up. To get around that I used "Inspect Element" on the lead convert button and converted it from HTML to Javascript. I would like this to work on any campaign member. The code I have technically works but for some reason when I click convert it sends me to a page with a convert button and when I click that it brings me to the custom conversion screen. I would like to get rid of the page with the convert button, because the button on Campaign Members layout should bring you directly to the conversion page. I think my button is written for a specific lead. How can I make sure it works on all? Am I going about this the right way? My code is below.

    document.write("<input value=\"Convert\" class=\"btn\" title=\"Convert\" name=\"convert_lead\" onclick=\"navigateToUrl('https:\/\/c.cs11.visual.force.com\/apex\/leadConvertPage?scontrolCaching=1&amp;id=00QZ0000008XRwq','DETAIL');\" type=\"button\">");

1 Answer 1

1

If your Visualforce Page uses a standardcontroller, then it would only be available as a button on that object. For example, if the page tag looks like this:

<apex:page standardcontroller="Lead" >

Hacking the button via the inspect element is not a good idea in this case, as the page will not function correctly as you are seeing. If you want the page to work from either location, you will probably need to create a dispatcher page that calls one from the other. The Page would look like this:

<apex:page standardcontroller="CampaignMember" extensions="convertCMEXT" action="{!redir}">

</apex:page>

//CONTROLLER
public with sharing class convertCMEXT {
private campaignMember cm {get; set;}
public convertCMEXT(ApexPages.StandardController controller) {
    cm=(CampaignMember)controller.getRecord();
}

public pagereference redir(){
pagereference pg = new pagereference('/apex/leadConvertPage');
pg.getParameters().put('id', cm.LeadID);
}

}

You must log in to answer this question.

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