0

I have a Salesforce query which is pulling all the necessary columns from Opportunity table. It is something like that

Select o.Opportunity_ID__c, o.LastModifiedDate, o.Opportunity_Currency__c, o.Opportunity_Type__c 
FROM Opportunity o
ORDER BY o.LastModifiedDate ASC

All I need is to add one more column. This column is called "EmployeeNumber" in "User" table.

When I loo at Opportunity fields, there is a lookup which is pulling this data called "Opportunity Owner" field in "Opportunity" table.

I tried couple of sub queries which didn't work. Some of the solutions I have seen on Google search; they say, look for Child Relationships. I did but there is no such a child relationship saying "User" or "Owner" under Opportunity child relationship (I used Eclipse for that)

Can you please help me? Thank you

ms_jordan
  • 151
  • 1
  • 1
  • 8

1 Answers1

1

You should be able to use SOQL-R to follow the Owner relationship, e.g.

Select Opportunity_ID__c, Owner.EmployeeNumber, .... From Opportunity ...

This won't work if Owner if polymorphic (it can point to multiple types) but from what i remember Oppty owner is a isn't one of those.

superfell
  • 18,780
  • 4
  • 59
  • 81
  • Millions times thank you. Your solution worked successfully. After adding Owner.EmployeeNumber, I got "Parent User" in Owner column and when I double click to that, I get to see EmployeeNumber. – ms_jordan Oct 14 '15 at 15:19