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
amarnijeramarnijer 

Display Account Owner on Case

Hi, I want to get Account Owner name from Opportunity.

I have written a soql like below

Select o.Account.Owner.LastName From Opportunity o . then I run it in eclipse.

it is giving a list of blank account.

 

I want to get it in a single query.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
Correct. That's why i was saying using eclipse, you can go only upto 1 level. If you need more thn one level data, use anonymous block.

All Answers

kiranmutturukiranmutturu

Select o.AccountId, o.Account.Owner.Name, o.Account.Owner.Employee_Number__c  from Opportunity o

Bhawani SharmaBhawani Sharma
Select Account.Owner.LastName from Opportunity where Account != null
amarnijeramarnijer

Sorry. It is not fromCase. It is from Opportunity.

Thanks @ tech Force, I added Where AccountId != null. but till it is not returning the owner name. do we have any setting upto how many lavel we can quory via chield to parent relationship?

kiranmutturukiranmutturu
oops case in the sense in this process not the standard object ....
kiranmutturukiranmutturu
you dont have field called lastname on user .. so u can get the same as like below...

Select o.AccountId, o.Account.Owner.Name, from Opportunity o
amarnijeramarnijer

Thanks kiran,

It is not dispalying any data.

Bhawani SharmaBhawani Sharma
Can you try this once
Select Account.Name, Account.OwnerId from Opportunity where AccountId != null
Bhawani SharmaBhawani Sharma

You can go into eclipse only upto one level. If you access any of the account field that will be displayed. But you cant see any other relationship data.

You can use execute anonymous block to see this information

amarnijeramarnijer

Hi Tech Force,

It is giving me the Woner Id, When I type Owner.LastName, it is not giving anything.

 

https://c.ap1.content.force.com/servlet/servlet.ImageServer?id=01590000001KtIQ&oid=00D90000000cCSu

Bhawani SharmaBhawani Sharma
Correct. That's why i was saying using eclipse, you can go only upto 1 level. If you need more thn one level data, use anonymous block.
This was selected as the best answer