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
sumit dsumit d 

visualforce page which return lead related to an Account

Hi all,
i want to make a visualforce page on account standard controller which shows All the converted and non converted leads related to the Acccount
in a VFP pageblock table, so in order to related i used a field on lead Referral_Source_lkid__c which relate the lead to Account id.
so i query required field on lead releted to Account record.
how to make a VFP on it? 
how to do it?
Any suggestions? 
<apex:page standardController="Account" recordSetVar="accounts"

              tabStyle="Account"

    sidebar="false">

    <apex:form >

        
 <apex:pageBlockSection title ="Leads">

 

            <apex:pageBlockTable value="{!account.Leads}" var="leadObj" id="leadObj_table">

                <apex:column value="{!leadObj.name}"/>

                <apex:column headerValue="Company">

                    <apex:inputField value="{!leadObj.Company}"/>
                </apex:column>

                <apex:column headerValue="Phone">

                    <apex:inputField value="{!leadObj.Phone}"/>

                </apex:column>
                <apex:column headerValue="Email">

                    <apex:inputField value="{!leadObj.Email}"/>

                </apex:column>
                <apex:column headerValue="CreatedDate">

                    <apex:inputField value="{!leadObj.phone}"/>

                </apex:column>
                <apex:column headerValue="OwnerAlias">

                    <apex:inputField value="{!leadObj.phone}"/>

                </apex:column>
                <apex:column headerValue="Juradiction">

                    <apex:inputField value="{!leadObj.phone}"/>

                </apex:column>
                <apex:column headerValue="Converted">

                    <apex:inputField value="{!leadObj.phone}"/>

                </apex:column>

            </apex:pageBlockTable>

        </apex:pageBlockSection>

    </apex:form>

</apex:page>
 User-added image i want a list of leads which is converted and non converted on Account record like above pic.
Best Answer chosen by sumit d
Ajay K DubediAjay K Dubedi
Hi Sumit,

If you want account and Lead both related. You need to create a custom controller.

public class DisplayAccountRelatedLeads {
    public List<Lead> records {get; set;} 
           public string recid{get;set;} 
         public DisplayAccountRelatedLeads(){ 
         records = [SELECT Id,Name,ConvertedAccount.Name,ConvertedAccountId,phone,Referral_Source_lkid__c  FROM Lead WHERE isConverted =true Limit 10];
        }
    } 
    
<apex:page Controller="DisplayAccountRelatedLeads" tabStyle="Account" sidebar="false">
<apex:pageBlockTable value="{!records}" var="acc" style="width:700px"> 


Refer This URL:
1) https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm
2) https://trailhead.salesforce.com/en/modules/visualforce_fundamentals/units/visualforce_custom_controllers
3) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_convertLead.htm


Please let me know if you have any query.

Thank You
Ajay Dubedi