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
Rick CulbrethRick Culbreth 

How to find the related Account Owner information in Lightning Component

I have a lightning Component on an object related to account. I am trying to get the account owner information to take different action based off owner.  I have tried several things but they all come back as undefined.  the lookup field on the custom object to account is called Practice_Provider.  Just wondering what the correct path, I can use ID or Name to do what I need.

Some of the code I have tried, all say undefined:
Window.alert('Account 1 Ownerid ' +               component.get('v.sObjectInfo.Practice_Provider__r.OwnerId')) 
         window.alert('Account 2 Owner.Id ' + component.get('v.sObjectInfo.Account.Owner.Id')) 
         window.alert('Account 3 Owner.Id ' + component.get('v.sObjectInfo.Practice_Provider__r.Owner.Id')) 
         window.alert('Account 3 Owner.Id ' + component.get('v.sObjectInfo.Account.OwnerId')) 
        window.alert('Sobject OwnerId ' + component.get('v.sObjectInfo.ownerId')) 
         window.alert('Sobject OwnerId ' + component.get('v.sObjectInfo.OwnerId')) 
        window.alert('Account Owner Name ' + component.get('v.sObjectInfo.Practive_Provider__r.Owner.Name')  )   
 if (''+component.get('v.sObjectInfo.Account.Business_Partner_Identifier_Code__c')+'' == 'FL')   ----- This part works it returns value in Account Field. 
Alain CabonAlain Cabon
You should post more info about your Apex controller or Lightning Data Service.

That could be interesting to display the complet object in the console.
var objectInfo = component.get(v.sObjectInfo);
console.log("sObjectInfo:" + JSON.stringify(objectInfo));

If you never read the field, you could never work with any try.
Alain CabonAlain Cabon
the complete object (typo)
Rick Culbreth 11Rick Culbreth 11
I tried that it was only show the account (Practice/Provider ID).  I made a formula field on the custom object that populated ownerid of the account on the custom object.  Checking that field worked.    
Alain CabonAlain Cabon
"sObjectInfo" is just a local content of the object in javascript (JSON). 

The content depends on the controller (apex) or a Lightning Data Service.

Without the component and the controllers (js / apex), it is impossible to verify the code

You have used one of these techniques: