+ Start a Discussion
Shruthi NarsiShruthi Narsi 

Display List of Partner leads Error On VF Page

I have written the eblow code to display partner leads. Can u fix the error for me and help  me in writing test class for the same

Apex class
public class PartnerLeadController {
    public class PartnerLeadsController {
    
    private final Lead l;
    
    public PartnerLeadsController(ApexPages.StandardController stdController) {
        this.l = (Lead)stdController.getRecord();
        initlead();
    }
    
    List<Lead> lead;
    
    public void initlead() {
        lead = [select id,OwnerId,Owner.Name,Status,LastName from Lead where Partner_Name__c = :l.id AND  LeadSource=: 'Partner' ORDER BY Name DESC];
    }
    
    public List<Lead> getlead () {
        return lead;
    }   
    
}

           

}

Vf page

public class PartnerLeadController {
    public class PartnerLeadsController {
    
    private final Lead l;
    
    public PartnerLeadsController(ApexPages.StandardController stdController) {
        this.l = (Lead)stdController.getRecord();
        initlead();
    }
    
    List<Lead> lead;
    
    public void initlead() {
        lead = [select id,OwnerId,Owner.Name,Status,LastName from Lead where Partner_Name__c = :l.id AND  LeadSource=: 'Partner' ORDER BY Name DESC];
    }
    
    public List<Lead> getlead () {
        return lead;
    }   
    
}

           

}

User-added image
Agustin BAgustin B
Hi the error is saying that you dont have a constructo for PartnerLeadController, why are you using a inner class?
Try using:
public class PartnerLeadController {
    
    private final Lead l;
    
    public PartnerLeadController(ApexPages.StandardController stdController) {
        this.l = (Lead)stdController.getRecord();
        initlead();
    }
.....
......

If it solves your question, please mark it as best answer, it may help others
Shruthi NarsiShruthi Narsi
public class PartnerLeadController {
    
   public final Account acc;
   
    public PartnerLeadController(ApexPages.StandardController stdController) {
        
        
        this.acc = (Account)stdController.getRecord();
        initlead();
    }
    List<Lead> lead;
    
    public void initlead() {
        lead = [select id,OwnerId,Owner.Name,Status,LastName,Name, Account__r.Id from Lead where Partner_Name__c = : acc.id  ORDER BY Name DESC];
    }
    
    public List<Lead> getlead () {
        return lead;
    }   
    
}

Vf page 

<apex:page standardController="Account" extensions="PartnerLeadController" lightningStylesheets="true" sidebar="false" >
   
    <style>
        body {
       
        }
    </style>
    <apex:pageBlock rendered="true">
        <apex:pageBlockTable value="{!lead}" var="l">
            <apex:column >
                <apex:outputLink value="/Lead/{!l.Id}/view" target="_top">{!l.Name}</apex:outputLink>
                <apex:facet name="header">Lead Name</apex:facet>
            </apex:column>
            <apex:column >
                
                <apex:facet name="header">Lead Name</apex:facet>
            </apex:column>
            <apex:column >
                <apex:outputLink value="/{!l.OwnerId}" target="_top">{!l.Owner.Name}</apex:outputLink>
                <apex:facet name="header">Owner Name</apex:facet>
            </apex:column>/>
            <apex:column ><apex:outputField value="{!l.Name}" />
                <apex:facet name="header">Name</apex:facet>
            </apex:column>
            <apex:column ><apex:outputField value="{!l.Status}" />
                <apex:facet name="header">Status</apex:facet>
            </apex:column>

        </apex:pageBlockTable>
    </apex:pageBlock>      
</apex:page>
Shruthi NarsiShruthi Narsi
list os not getting displayed
 
Agustin BAgustin B
hi Shruthi, try this:
public final Account acc;
public  List<Lead> lead {get;set;};   
    public PartnerLeadController(ApexPages.StandardController stdController) {
   
        
        acc = (Account)stdController.getRecord();
 lead = [select id,OwnerId,Owner.Name,Status,LastName,Name, Account__r.Id from Lead where Partner_Name__c = : acc.id  ORDER BY Name DESC];
    }
   
}

Solve any compilation issues and try again.
Let me know if it solved your issue.