You need to sign in to do that
Don't have an account?

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;
}
}
}

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;
}
}
}
Try using:
If it solves your question, please mark it as best answer, it may help others
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>
Solve any compilation issues and try again.
Let me know if it solved your issue.