Im new to LWC development and am trying to get through an issue Im having. I want to use a custom class list to display a list of data in a data table. The data that Im populating manually (at the moment) is not displaying. Any advice is appreciated. Thank you for your time!


    <lightning-card title="Handle Error" icon-name="standard:contact">
        <template if:true={error}>
    <lightning-card title="People"> 
        <lightning-datatable data={people} columns={columns} key-field="accountid"></lightning-datatable>        

import { LightningElement, wire, track, api} from 'lwc';

import getpeople from '@salesforce/apex/Onboarding.getpeople';

export default class OnboardingPeople extends LightningElement {

    @api people = [];
    @track error;

    @track columns = [
            label: 'First Name',
            fieldName: 'nameUrl',
            type: 'url',
            typeAttributes: {label: { fieldName: 'firstname' }, 
            target: '_blank'},
            sortable: true
            label: 'Last Name',
            fieldName: 'lastname',
            type: 'text',
            sortable: true


    wiredPeople({error, data}){

            this.people = data;
            this.error = undefined;
        } else if (error) {

            this.people = undefined;
            this.error = error;


public with sharing class Onboarding {

    public static List<OnboardingPeopleResult> getpeople(String recordId) {

        List<OnboardingPeopleResult> oprList = new List<OnboardingPeopleResult>();

        OnboardingPeopleResult oprobj = new OnboardingPeopleResult();
        oprobj.accountid = '123';
        oprobj.firstname = 'Tom';
        oprobj.lastname = 'Snow';
        oprobj.nameUrl = '/'+oprobj.accountid;


        return oprList;
Custom Class

public class OnboardingPeopleResult {

    public String accountid {get;set;} 
    public String firstname {get;set;} 
    public String lastname {get;set;} 
    public String nameUrl {get;set;} 

    public OnboardingPeopleResult() { 
        this.accountid = '';
        this.firstname = '';
        this.lastname = '';
        this.nameUrl = '';



enter image description here


That code work ok in my test org when I just added it to a record detail page (though I had to add

@api recordId;

If you want to use the LWC in a quick action, you should follow the solution here, and wrap it in a aura component - something like this:

<aura:component implements="force:hasRecordId,force:lightningQuickActionWithoutHeader">
    <c:myonboard recordId="{!v.recordId}></c:myonboard>
  • thank you for the response. I added the line of code you recommended but Tom still isn't displaying. As for the Aura Wrapper Im not sure what that is unfortunately. I made my LWC visible to an App Page by setting the Target "lightning__AppPage" in the LWC's meta.xml file. But that is all that I have done for getting the LWC to display on a page. Here's that xml file..
    – user891859
    Oct 9 '19 at 17:51
  • ``` <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="soap.sforce.com/2006/04/metadata" fqn="OnboardingPeople"> <apiVersion>46.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle> ```
    – user891859
    Oct 9 '19 at 17:51
  • So if this is on an app page, Tom won't appear because recordId is always NULL. I added the component to an account detail page, and then it worked because recordId is automatically populated to be the current record. Having said that, even on an App Page, I don't get the error you are seeing Oct 9 '19 at 20:21
  • How did you add the LWC to a button? It’s not listed in the available lightning components when I go to create the button.
    – user891859
    Oct 10 '19 at 13:21
  • You mean via a quick action? If so, you'll need to use an aura component that implements quickaction interface Oct 10 '19 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.