Salesforce Lightning Component

0 votes

I am creating a salesforce lightning component to list the leads of the current logged in user.

I have managed to write the following code, but when i add the component to the page, and preview it, I dont see any leads.

<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>
    </div>


Please tell me what is the mistake here.

Mar 30, 2022 in SalesForce by surbhi
• 3,820 points
872 views

1 answer to this question.

0 votes

This may be because

  1. You have not added a controller on your lightning component.

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

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

    controller.set("v.leads", variableWithLeadsList);
    
  4. 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.

Hope this helps!

Join Salesforce Training to learn more.

Thanks!

answered Apr 1, 2022 by CoolCoder
• 4,420 points

edited Jun 27, 2023 by Khan Sarfaraz

Related Questions In SalesForce

0 votes
1 answer

Json response to be deserialized in Apex salesforce lightning

Because some fields in Apex Salesforce are ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,820 points
3,563 views
0 votes
0 answers

Can we create new Search Layout in Lightning SalesForce?

I am working on the Search Layout, ...READ MORE

Mar 4, 2022 in SalesForce by surbhi
• 3,820 points
504 views
0 votes
0 answers

Salesforce Apex SingleEmailMessage with Template to User not contact

Im trying to send an email in ...READ MORE

Feb 28, 2022 in SalesForce by surbhi
• 3,820 points
3,042 views
0 votes
1 answer

Cannot login to Salesforce Sandbox via python API

Set domain='test' and generate a new token ...READ MORE

answered Mar 1, 2022 in SalesForce by CoolCoder
• 4,420 points
1,850 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
3,403 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
1,046 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
759 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 729 views
0 votes
1 answer

How to Update RecordTypeId field in Lightning record form in salesforce?

A critical action that messes everything up ...READ MORE

answered Mar 3, 2022 in SalesForce by CoolCoder
• 4,420 points
3,355 views
0 votes
1 answer

Salesforce Lightning - Login Failure In Staging

https://test.salesforce.com versus https://login.salesforce.com. Even if you use ...READ MORE

answered Mar 9, 2022 in SalesForce by CoolCoder
• 4,420 points
689 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP