You need to sign in to do that
Don't have an account?

Hello, I wrote program for datatable but the records are not displaying on the UI. Please help me
Controller
public with sharing class datatablecont {
@AuraEnabled(cacheable=true)
public static List<BMCServiceDesk__Incident__c> getInc(){
return [select id,name from BMCServiceDesk__Incident__c ]; }
}
JS
import { LightningElement,wire,track } from 'lwc';
import getInc from '@salesforce/apex/datatablecont.getInc';
const colm = [
{label:'Id', fieldName:'Id', type:'id'},
{label:'Name', fieldName:'Name', type:'text'}
]
export default class Datatable extends LightningElement {
@track col = colm;
@wire(getInc) getIncident;
}
HTML
<template>
<lightning-card title="Incident Tickets">
<lightning-datatable key-field="Id" data={getIncident} columns={col}></lightning-datatable>
</lightning-card>
</template>
public with sharing class datatablecont {
@AuraEnabled(cacheable=true)
public static List<BMCServiceDesk__Incident__c> getInc(){
return [select id,name from BMCServiceDesk__Incident__c ]; }
}
JS
import { LightningElement,wire,track } from 'lwc';
import getInc from '@salesforce/apex/datatablecont.getInc';
const colm = [
{label:'Id', fieldName:'Id', type:'id'},
{label:'Name', fieldName:'Name', type:'text'}
]
export default class Datatable extends LightningElement {
@track col = colm;
@wire(getInc) getIncident;
}
HTML
<template>
<lightning-card title="Incident Tickets">
<lightning-datatable key-field="Id" data={getIncident} columns={col}></lightning-datatable>
</lightning-card>
</template>
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
Refer the below link have solution for similar kind of ask and modify the logic as per your need.
https://developer.salesforce.com/forums/?id=9062I000000gBxIQAU
https://www.sfdckid.com/2021/07/how-to-fetch-data-in-lwc-salesforce.html
If this information helps, Please mark it as best answer.
Thanks!!
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!