I am trying to flatten the @wire decorator so i can get __r fields into my datatable, and I am failing miserably
let me show you what i have tried, none of which has worked
try 1: mapping
columns = [
{ label: 'Name', fieldName: 'Name' },
{ label: 'Household Name', fieldName: 'HouseholdName'}
];
@api recordId;
householdTags;
@wire(getData, {FundInterestPriorityId: '$recordId'})
wiredContacts({ error, data }) {
if (this.data) {
this.data = this.data.map(row=>{
return{...row, HouseholdName: row.ucinn_ascendv2__Account__r.Name}
})
this.householdTags = this.data;
try 2: object / array mapping
if (this.data) {
let preparedAssets = [];
this.data.forEach(asset => {
let preparedAsset = {};
preparedAsset.Name = asset.Name;
preparedAsset.HouseholdName = asset.ucinn_ascendv2__Account__r.Name;
preparedAssets.push(preparedAsset);
window.console.log(preparedAssets)
});
this.data = preparedAssets;
this.householdTags = this.data;
my html
<lightning-datatable
key-field="id"
data={householdTags}
columns={columns}>
</lightning-datatable>