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
Ron Mccrerey 20Ron Mccrerey 20 

How do you get LWC to recognize compound fields? (rstk__poline_ordno__r.Name)

How do you get LWC to recognize compound fields? (rstk__poline_ordno__r.Name)
LWC does not appear to recognize compound fields names.
Best Answer chosen by Ron Mccrerey 20
Ron Mccrerey 20Ron Mccrerey 20
I got this to work by create a new object. The Account.Name from the controller was changed AccountName in the new object.
Example:
@track columns = [
{
label: 'Name',
fieldName: 'AccountName',
type: 'text',
sortable: true
},
{
label: 'AccountId',
fieldName: 'AccountId',
type: 'text',
sortable: true
},
{
label: 'Id',
fieldName: 'Id',
type: 'text',
sortable: true
}
];

@wire(retreive, {
id: '$recordId'
}) wireRetreive(value) {
if (value.error) {
this.error = value.error;
} else if (value.data) {
let tempData = [];
for (const iterator of value.data) {
tempData.push( {Id: iterator.Id, AccountName: iterator.Account.Name,
AccountId: iterator.Name });
}
this.something = value.data[0].Account.Name;
this.data = tempData;
}
}
}

All Answers

Raj VakatiRaj Vakati
I am little confused  from this rstk__poline_ordno__r.Name).. you are talking about compound  fields or related object fields ??
Ron Mccrerey 20Ron Mccrerey 20
Yes it would be in this case related object fields, but I have the problem with any field that has a dot extension in it another example is: 
Opportunity[0].OpportunityLineItems[0].Product2.Serial_Number__c
Ron Mccrerey 20Ron Mccrerey 20
I got this to work by create a new object. The Account.Name from the controller was changed AccountName in the new object.
Example:
@track columns = [
{
label: 'Name',
fieldName: 'AccountName',
type: 'text',
sortable: true
},
{
label: 'AccountId',
fieldName: 'AccountId',
type: 'text',
sortable: true
},
{
label: 'Id',
fieldName: 'Id',
type: 'text',
sortable: true
}
];

@wire(retreive, {
id: '$recordId'
}) wireRetreive(value) {
if (value.error) {
this.error = value.error;
} else if (value.data) {
let tempData = [];
for (const iterator of value.data) {
tempData.push( {Id: iterator.Id, AccountName: iterator.Account.Name,
AccountId: iterator.Name });
}
this.something = value.data[0].Account.Name;
this.data = tempData;
}
}
}
This was selected as the best answer