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

Lead List View Custom Button

Hello Everyone,

Recently somebody very helpful from the community resolved my problem but still two points missing, can anybody please help?


We would like to replace the standard button called Change Status on lead list view to add more fields. This is done but when i click on the new button it doesnt check if we have selected any record on the list view therefore a validation is required, if atleast one record is selected. I placed a java script which works fine with one record but fails when multiple records are selected.

VF page has two dependent picklist which needs to be updated as well, using below code the master picklist changes but dependent doesnt.

Secondly, i want redirection to work, after clicking save, how can i redirect to the same list view?

Here is the Code
<apex:page controller="LeadStatusChange" tabStyle="Lead">
    <script src="" type="text/javascript"></script>

    <img src="../s.gif" alt="Lead"  class="pageTitleIcon" title="Lead"/><br />
    <h1 class="pageType noSecondHeader">Select New Status</h1>

        function handleColumnPicklistChangeEvent(argSelectEle) {
            var jnc = jQuery.noConflict();

            jnc('.StatusChildList').each(function(argEle) {
                this.selectedIndex = argSelectEle.selectedIndex;
    <apex:form >
        <apex:pageBlock title="Change Status">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Save}" value="Save" />
                <apex:commandButton action="{!cancel}" value="Cancel" />
            <apex:variable value="{!1}" var="ind" />
            <apex:pageBlockTable value="{!mLeadRecs}" var="leadRec">
                <apex:column headerValue="#">
                    <apex:outputText value="{!ind}" />
                <apex:column >
                    <apex:facet name="header">
                        <apex:outputPanel >
                            <apex:outputLabel value="Status: " for="StatusMainList" />
                            <apex:selectList id="StatusMainList" size="1" multiselect="false" 
                                <apex:selectOptions value="{!StatusPicklist}" />    
                    <apex:inputField value="{!leadRec.status}" styleClass="StatusChildList" /> 
                <apex:column headerValue="Recycled Reason">
                <apex:inputField value="{!leadRec.Recycled_Reason__c}"/>
                    <!-- <apex:inputField value="{!leadRec.Recycled_Reason__c}"/> -->
                <apex:column headerValue="Unqualified Reason">
                <apex:inputField value="{!leadRec.Unqualified_Reason__c}"/>
                    <!-- <apex:inputField value="{!leadRec.Unqualified_Reason__c}"/> -->
                <apex:variable value="{!ind + 1}" var="ind" />
public with sharing class LeadStatusChange {
    public List<Lead> mLeadRecs {get;set;}

    public LeadStatusChange () {
        String lStrLeadID = ApexPages.currentPage().getParameters().get('ids');
        mLeadRecs = [SELECT id, name,status, Recycled_Reason__c, Unqualified_Reason__c FROM Lead WHERE id IN:lStrLeadID.split(',')];

    public PageReference save() {
        update mLeadRecs;
        return new PageReference('/00Q/o');

    public PageReference cancel() {
        return new PageReference('/00Q/o');

public List<SelectOption> getStatusPicklist() {

        List<SelectOption> lOptions = new List<SelectOption>();


        for(Schema.PicklistEntry lFieldMeta : Lead.Status.getDescribe().getPicklistValues()) {
            lOptions.add(new SelectOption(lFieldMeta.getValue(), lFieldMeta.getLabel()));



        return lOptions;