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
SFDC Admin12SFDC Admin12 

Lead component not working

Hi,

created a lightning component to display the list of Lead of the current logged in user.

I write the following code to get the Lead, when i add the component to the page, and preview it, I dont see any Lead.


<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" > <div class="slds"> <table class="slds-table slds-table--bordered slds-table--striped"> <thead> <tr> <th scope="col"><span class="slds-truncate">Company</span></th> <th scope="col"><span class="slds-truncate">Annual Revenue</span></th> </tr> </thead> <tbody> <aura:iteration items="{!v.leads}" var="lead"> <tr> <td>{!lead.Company}</td> <td>{!lead.AnnualRevenue}</td> </tr> </aura:iteration> </tbody> </table>
Best Answer chosen by SFDC Admin12
AbhishekAbhishek (Salesforce Developers) 
Hi,

You can follow the tutorial for Displaying a Contact List and replace the Logic with that for Leads
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm

And

This might be because

You have not added a controller on your lightning component.

<aura:component implements="forceCommunity:availableForAllPageTypes" controller="ContactController" access="global" >
You have not declared the attribute "leads" which you have used in the iteration.

<aura:attribute name="leads" type="Lead[]"/>
You have not set the "leads" attribute which you fetched from the Apex controller.

controller.set("v.leads", variableWithLeadsList);
You have not fetched data from the Apex controller. In this case, as mentioned by Rajdeep Dua, https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_one_demo_load.htm link explains the whole process and will help you if you replace Contact with Lead.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.