Salesforce not letting select country from a relationship, but allows name and id

I am running the following query in salesforce to get the country

SELECt name, owner.country from lead 

This gives the following error:

No such column 'country' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. 

However this works just fine if I do

SELECt name, owner.id from lead SELECt name, owner.username from lead SELECt name, owner.name from lead 

It gives the data

Replay

This is a result of the OwnerId field on Lead being a 'Polymorphic' relationship field i.e. it relates to more than one object (User or Group).

This field actually looks up to a 'Name' object. You can use the Force.com IDE schema browser to see what fields are available on this object:

Salesforce not letting select country from a relationship, but allows name and id

As you can see, there is no 'Country' field hence the error you're getting.

There's a great article on the subject here

backed up by SFDC documentation here

and here

Category: soql Time: 2014-08-29 Views: 1
Tags: soql

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.230 (s). 12 q(s)