简体   繁体   中英

Salesforce Lightning Component

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>

It will be great, if someone could tell me what is that I am doing wrong. Thank you

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

This might 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM