+ Start a Discussion
Vijaya Kumar RegantiVijaya Kumar Reganti 

How to query on opportunityLineItem to get the Opportunity.territory field from opportunity

Hi Friends,

 

I have a requirement to do the following query.

 

[Select Opportunity.Territory from OpportunityLineItem]  

 

 


When I have tried this, I am getting an error like there is no entity "Territory"  on "Opportunity" Object.

 

Please help in this regard.

 

Thanks,

 

Vijay

Best Answer chosen by Admin (Salesforce Developers) 
Vijaya Kumar RegantiVijaya Kumar Reganti

Hi Friends,

 

Finally i got my answer.To get the territory name,

 

[Select Opportunity.Territory from OpportunityLineItem]  

 


instead of the above query I have used [Select Opportunity.Territory.Name from OpportunityLineItem]  

 

It Worked.

 

Thanks,

 

Vijay

All Answers

bob_buzzardbob_buzzard

I don't believe that territory is a regular field - check out this thread on accessing the territory of an account - I'd expect a similar pattern for opportunities:

 

http://boards.developerforce.com/t5/Apex-Code-Development/how-do-i-get-the-territory-for-an-account-in-apex-api/td-p/84825

Vijaya Kumar RegantiVijaya Kumar Reganti

Hi Friends,

 

Finally i got my answer.To get the territory name,

 

[Select Opportunity.Territory from OpportunityLineItem]  

 


instead of the above query I have used [Select Opportunity.Territory.Name from OpportunityLineItem]  

 

It Worked.

 

Thanks,

 

Vijay

This was selected as the best answer