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 in SalesForce by surbhi
• 3,810 points
27 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.

answered Apr 1 by CoolCoder
• 4,360 points

Related Questions In SalesForce

0 votes
1 answer

Json response to be deserialized in Apex salesforce lightning

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

answered Mar 2 in SalesForce by surbhi
• 3,810 points
103 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 in SalesForce by surbhi
• 3,810 points
59 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 in SalesForce by surbhi
• 3,810 points
191 views
0 votes
0 answers

Cannot login to Salesforce Sandbox via python API

I am using the python3.7.2 module simple-salesforce==0.74.2 and I ...READ MORE

Mar 1 in SalesForce by surbhi
• 3,810 points
98 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
1,830 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,010 points
287 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,010 points
173 views
0 votes
1 answer

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

Hi @Vardhan, I took Edureka's Salesforce Training that covers all ...READ MORE

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

edited Dec 22, 2021 by Soumya 202 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 in SalesForce by CoolCoder
• 4,360 points
191 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 in SalesForce by CoolCoder
• 4,360 points
93 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP