I am writing an LWC component to display history object results of a custom object. I am unable to retrieve field label from "FIELD" in _history object. Tried to build the logic in component.js, you can see from the code i have assigned the value "Total Price" to "Totalprice__c" field. But this applies to entire row in my result even for other fields also.
Any help would be appreciated.
Below is my code:
Component.JS
import { LightningElement, wire, track } from 'lwc';
import getTenantDetailList from '@salesforce/apex/Testcurrenycontroller.getPriceDetailList';
// Datatable Columns
const columns = [
{
label: 'Old Value',
fieldName: 'OldValue',
type: 'text',
}, {
label: 'New Value',
fieldName: 'NewValue',
type: 'text'
}, {
label: 'Field',
fieldName: 'Field',
type: 'text'
}, {
label: 'Created Date',
fieldName: 'CreatedDate',
type: 'Date'
}, {
label: 'CreatedById',
fieldName: 'CreatedById',
type: 'Id'
}
];
export default class ReferenceDataInLwcDatatable extends LightningElement {
@track data = [];
@track columns = columns;
@wire(getPriceDetailList)
opp({error, data}) {
if(data) {
let currentData = [];
// let fielddata = [];
var Data = [];
data.forEach((row) => {
let rowData = {};
rowData.Id = row.Id;
rowData.OldValue = row.OldValue;
rowData.NewValue = row.NewValue;
//rowData.Field = row.Field;
if (rowData.Field = 'TotalPrice__c' ) {
Data = 'Total price';
}
rowData.Field = Data;
currentData.push(rowData);
});
this.data = currentData;
}
else if(error) {
window.console.log(error);
}
}
}