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
Sid LightningSid Lightning 

Getting owner id and not owner name on lightning component screen

Hi,

I am getting owner id in the data table for lightning component, when using

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            
            {label: 'Created By', fieldName: 'Owner__c'},

and no value when I try to use :

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            
            {label: 'Created By', fieldName: 'Owner__r.Name'},

on lightning component screen.

Also , the records that get created on save are displayed in tabular form, but gets saved randomly in table ordrer, i want to arrange them in order of creation time, with the last created record to be on the top of table
GulshanRajGulshanRaj
Are you using standard owner field. If yes then it should be owner.name instead of owner__r.name.


Thanks
Gulshan Raj
Santosh Kumar 348Santosh Kumar 348
Hi Sid,

As you have mentioned that below code is working for you, but you haven't mentioned anything avout how you are showing the data eitheryou have used LDS or Apex class in backend.
 
{label: 'Account Name', fieldName: 'linkName', type: 'url', 
typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            
 {label: 'Created By', fieldName: 'Owner__c'},

So assuming 'Owner__c' is a custom field, you need to include this field in your query "owner__r.name" if you wanna refer the same.

If this is a typo and you are using the Standard field then use "Owner.name" instead of "owner__r.name" in your code.

If it helped then can you please mark it as the best answer so that it can be used by others in the future.

Regards,
Santosh Kumar