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
Vandana RattanVandana Rattan 

Display SOQL results in Visualforce page

I have created a Custom Lead Convert Page. I need to show a list of duplicate contacts on Lead Conversion. I have been trying to do so using Apex:Repeat and Apex:PageBlockTable but nothing is getting displayed. My SOQL does return results. Kindly suggest. My Controller and Visualforce Page are given below:-

VisualForce Page:
<apex:page standardController="Lead" extensions="LeadConvertController">
    <apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" />
     <apex:sectionHeader title="Convert {!$ObjectType.Lead.label}" subtitle="{!Lead.name}"/>
    <apex:form id="leadForm">
        <apex:pageBlock mode="edit" >
       
        <apex:pageblockbuttons >
                <apex:commandbutton value="Convert" action="{!ConvertLead}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
        </apex:pageblockbuttons>
        
        <apex:pageblocksection id="LeadConvertPBS" title="Convert Lead">
        	<apex:pageBlockSectionItem >
            <apex:outputLabel value=" Record Owner" for="Record Owner"/>
                <apex:inputField value="{!lead.OwnerID}" id="recOwner1" />
            
          	</apex:pageBlockSectionItem>
            
            <apex:pageBlockSectionItem >
            <apex:outputLabel for="Account Name">Account Name</apex:outputLabel>
             <apex:inputField required="true" id="company" value="{!lead.Company}" />
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
           <apex:OutputLabel for="Send Email to the Owner">Send Email to the Owner</apex:OutputLabel>
           <apex:inputCheckbox onclick="{!lead.Ownerid}"/>
           </apex:pageBlockSectionItem> 
          <apex:pageBlockSectionItem >
            <apex:outputLabel for="Oppt Name">Opportunity Name:</apex:outputLabel>
             <apex:inputField required="true" id="opptName" value="{!lead.Company}" />
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem >
                      <apex:outputLabel for="ConStatus">Converted Status:</apex:outputLabel>
             <apex:inputField id="ConStatus" value="{!lead.Status}" />
          </apex:pageBlockSectionItem>
          <apex:pageblockSectionItem >
             <!-- <apex:outputLabel for="no oppty">Do not create new opportunity upon conversion</apex:outputLabel>
              	<apex:inputCheckbox id="noOppty"/>-->
               
          </apex:pageblockSectionItem>
        </apex:pageblocksection> 
        <!--<apex:outputPanel id="contactList" layout="block">
        	<apex:pageBlockSection title="Contact List">
            </apex:pageBlockSection>
            <apex:repeat value="{!lstDupContact}">
				<apex:outputText value="{!lstDupContact}"></apex:outputText>            
            </apex:repeat>
        </apex:outputPanel>-->
        <apex:pageBlockTable value="{!lstDupContact}" var="ct">
            <apex:column value="{!ct.id}"/>
            <apex:column value="{!ct.firstName}"/>
        	<apex:column value="{!ct.lastName}"/>
        </apex:pageBlockTable>
		
            
        </apex:pageBlock>
        
    </apex:form> 
    
</apex:page>
public class LeadConvertController{
    Lead lead;
    public List<Contact> lstDupContact {get; set;}
    
    public LeadConvertController(ApexPages.StandardController controller) {
		this.lead = (Lead)controller.getRecord();
	}
    
    public PageReference ConvertLead(){
        System.debug('Inside Lead Convert Controller');
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(lead.Id);
        Lead leadRecord = [SELECT firstName, lastName, email from lead where id =: lead.Id];
        System.debug('lead Owner >> ' + lead.OwnerId);
        //GroupMember grpMember = [Select UserOrGroupId from groupmember where groupid= :lead.OwnerId];
        //System.debug('GroupMember--->' + grpMember.UserOrGroupId);
        //lc.setOwnerId(grpMember.UserOrGroupId);
        lc.setConvertedStatus('Qualified'); 
       // Database.LeadConvertResult lcr = Database.convertLead(lc); 
        //if(lcr.isSuccess()){
          //  String aId = lcr.getAccountId();
            
            lstDupContact = [SELECT id, firstName, lastName, email from Contact where (firstName =: leadRecord.FirstName OR lastName =: leadRecord.LastName) AND email =: leadRecord.email];
            System.debug('lstDupContacts >>>' + lstDupContact);
           
            
            PageReference redirect = new PageReference('https://c.cs7.visual.force.com/apex/CustomLeadConvert?retURL=%2F00QM0000005IVfb&scontrolCaching=1&id=00QM0000005IVfb&id=' + lead.Id + '&sfdc.override=1');
            redirect.setRedirect(false);
            return redirect;
        //}
        return new PageReference('/'+'');
    }
    
    public List<Contact> getLstDupContact(){
        return lstDupContact;
    }
    
 
}


Best Answer chosen by Vandana Rattan
James LoghryJames Loghry
Try returning null at line 31 (instead of a new PageReference).  Also, add a rerender="leadForm" to your Convert command button.  See if that helps.

All Answers

James LoghryJames Loghry
Try returning null at line 31 (instead of a new PageReference).  Also, add a rerender="leadForm" to your Convert command button.  See if that helps.
This was selected as the best answer
Vandana RattanVandana Rattan
Thanks a ton James. It worked..