function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DolgoldyDolgoldy 

Not receving data in datatable in lwc

HI all,
There is one field i.e. work order which is not feching data from ui please tell me resson below is my code
// apex class

public with sharing class ProjectLineItemHelper

  {
    @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }
          /*   @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemWorkOrderList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }*/
      
      
}
 
// .js file

import { LightningElement ,api, wire, track} from 'lwc';
import getprojectlineItemList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemList';
//import getprojectlineItemWorkOrderList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemWorkOrderList';
export default class projectLineItemAddTable extends LightningElement {
     @api recordId;
    // @api recordid;

    @track columns = [{label: 'Work Order name',
            fieldName: ' Project_Work_Order__c',
            type: 'text',
            sortable: true

    },
        {
            label: 'Line Item name',
            fieldName: 'Name',
            type: 'text',
            sortable: true
        },
        {
            label: 'Description',
            fieldName: 'Decription__c',
           type : 'Text',
            sortable: true
        },
        {
            label: 'Area of House',
            fieldName: 'Area_Of_House__c',
          type: 'picklist',
            sortable: true
        },
       {
            label: 'Status',
            fieldName: 'Line_Item_Status__c',
           type: 'picklist',
            sortable: true
        },
        {
            label: 'Qty Type',
            fieldName: 'QTY_Type__c',
          type : 'picklist',
            sortable: true
        },
        {
            label: 'Qty',
            fieldName: 'QTY__c',
            type: 'text',
 	        sortable: true
        },
        {
            label: 'Rate',
            fieldName: 'Rate__c',
            type: 'currency',
            sortable: true
        },
	{
            label: 'Total',
            fieldName: 'Total__c',
           type : 'text',
            sortable: true
        },
        
    ];
 
    @track error;

    @track lineItemList ;
    //selectedWOName = '';



    //to filterline item  record using project id
    @wire(getprojectlineItemList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }
    // to filter work order
    /* @wire( getprojectlineItemWorkOrderList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }*/


}
 
//, Html
<template>
    <!--h1 font-size:60px> Project Line Items</h1-->
     <div class="slds-box slds-theme_default">
    <lightning-card>
      <h3 slot="title" class="slds-text-title_bold">
        <lightning-icon
          icon-name="standard:client"
          size="medium">
        </lightning-icon>
        <span class="slds-m-left_small">
          Project Line Items</span>
        
      </h3>
    <!-- <template if:true={lineItemList}> -->
        <lightning-datatable data={lineItemList} columns={columns} key-field="Id"  hide-checkbox-column="true" >
            
 
        </lightning-datatable>
    <!-- </template> -->
    
    <template if:true={error}>
        {error}
    </template>
    </lightning-card>
    </div>
</template>


 
mukesh guptamukesh gupta
Hi Dolgoldy,

Please update in your code:-
 
{label: 'Work Order name',
 fieldName: 'Project_Work_Order__r.name',
 type: 'text',
 sortable: true
 }

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
DolgoldyDolgoldy
Thank you mukesh but its not working
mukesh guptamukesh gupta
One more thing , you need to debug 
 
console.log('this.lineItemList ==>> '+JSON.stringify(this.lineItemList));

want to make sure about value of Project_Work_Order__r.name

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh