You need to sign in to do that
Don't have an account?
Akshay Sethia
LWC: Lightning DataTable Lookup Issue
Hello Folks, im new to the salesforce org, and i was working on a project. I have completed the whole project but i am just stuck at one point. The situation is as follows:
Note: I have used Apex class to fetch the data and in that i am able to retive the values to the front end. (Check using console.log).
Also, i have tried using all combos of ObjectA__r.NamedField__c, ObjectA__c.NamedField__c and all. I had no reults when i did so.
I also ran the SOQL query in anonymous window and the results were as i expected.
Please help me out, over here in how to display the ObjectA -> NamedField__c field in the lightning datatable of Salesforce.
Thanks In advance, help would be much appriciated .
- There are 2 objects(Custom), lets consider them as Object A and Object B.
- I have a lookup relationship on Object A from Object B.
- Consider i have a text field in Object A Named "NamedField__c".
- I have made LWC for the Object B to display all the columns using Lightning DataTable.
Note: I have used Apex class to fetch the data and in that i am able to retive the values to the front end. (Check using console.log).
Also, i have tried using all combos of ObjectA__r.NamedField__c, ObjectA__c.NamedField__c and all. I had no reults when i did so.
I also ran the SOQL query in anonymous window and the results were as i expected.
Please help me out, over here in how to display the ObjectA -> NamedField__c field in the lightning datatable of Salesforce.
Thanks In advance, help would be much appriciated .
Please check the columns variable you are using for the lightning-dataTable, it should contain ObjectA__r.NamedField__c.
If still it doesn't show up, then you need to send the data to LWC as wrapper class with all the fields.
office.com/setup (http://www.officesetup.help)
office.com/setup (http://w-ww-office.com/setup)
mcafee.com/activate (http://www.help-mcafee.me)
mcafee.com/activate (http://w-w-w-mcafee.com/activate)
Js Code Snippet -
const columns = [
{ label: 'Voucher Id', fieldName: 'Name' },
{ label: 'Voucher Name', fieldName: 'Voucher_Name__c' },
{ label: 'Voucher Cost', fieldName: 'Voucher_Cost__c', type: 'currency', typeAttributes: { currencyCode: 'INR' }, cellAttributes: { alignment: 'left' } },
{ label: 'Voucher Validity', fieldName: 'Validity__c' },
{ label: 'Active', fieldName: 'Active__c' },
{ label: 'Certification Name', fieldName: 'Certification__r.Cert_Name__c', type: 'text' },
{ label: 'Voucher Comments', fieldName: 'Comments__c' },
{
type: 'action',
typeAttributes: {
rowActions: actions,
}
}
];
@wire(getVoucherList)
Voucher__c(result) {
this.refreshTable = result;
if (result.data) {
this.vouchers = result.data;
this.error = undefined;
} else if (result.error) {
this.vouchers = undefined;
this.error = result.error;
}
if (this.error != undefined) {
console.log(this.error);
} else {
console.log(result.data);
}
}
HTML code snippet -
<template if:true={vouchers}>
<lightning-datatable key-field="Id" data={vouchers} columns={columns} hide-checkbox-column="true"
onrowaction={handleRowActions}>
</lightning-datatable>
</template>
CLass snippet -
@AuraEnabled(Cacheable=true)
public static List<Voucher__c> vouData(){
return [ SELECT Name, Active__c, Certification__r.Cert_Name__c, Comments__c, Id, Validity__c, Voucher_Cost__c, Voucher_Name__c FROM Voucher__c ORDER BY Id ASC NULLS FIRST LIMIT 10 ];
}
This is my code Danish, could you help by explaining how to use wrapper classes here?
You can refer below sample code: