I'm trying to get a list of records(child records of opportunity object), and display them in a lightning datatable on the opportunity lightning record page. However I'm unable to invoke apex method from salesforce lwc, and cannot get it to work. Below are the lwc components & apex class. Is there something that I'm missing?
opptyapplicationlist.html
<template>
<lightning-datatable columns={columns} data={data} key-field="Name">
</lightning-datatable>
</template>
opptyapplicationlist.js
import {LightningElement, track, wire, api} from 'lwc';
import getApplicationListRecords from '@salesforce/apex/ApplicationRelatedListController.getApplicationListRecords';
const columns=[
{label:"Application Ref #", fieldName:"Name", type:"text"},
{label:"Account Name", fieldName:"Account_Name__c", type:"text"},
{label:"Category", fieldName:"Category__c", type:"text"},
{label:"Date Received", fieldName:"Date_Received__c", type:"date"}
];
export default class OpptyApplicationList extends LightningElement {
@api recordId;
@wire(getApplicationListRecords, {strOppId: '$recordId' }) data;
@track columns = columns;
}
ApplicationRelatedListController.apxc
public class ApplicationRelatedListController {
@AuraEnabled(cacheable=true)
public static List<Application__c> getApplicationListRecords(String strOppId){
return [SELECT Id, Name, Account_Name__r.Name, Category__c, Date_Received__c FROM Application__c WHERE Opportunity__c =:strOppId];
}
}