+ Start a Discussion
Sharru75Sharru75 

SOQL Query

System.debug([SELECT What.Subject FROM Task ORDER BY CreatedDate DESC]);

SELECT What.Subject FROM Task ORDER BY CreatedDate DESC 

Why this is query is not working????

Task is having lookup with case and the relation ship name is "What"

 

 

Please give the reason

 

 

Thanks in advance

 

 

 

Sharru75Sharru75

i'm getting this error

 

 

INVALID_FIELD: 
SELECT What.Subject FROM Task ORDER BY
^
ERROR at Row:1:Column:8
No such column 'Subject' 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.

 

Sharru75Sharru75

No such column 'Subject' on entity 'Name' what this means????????

Sharru75Sharru75

Please Help

vishal@forcevishal@force

Subject is a field on Task object, so if you're looking for that field, simply query

 

Select Subject From Task Where.. (your conditions)

 

If you want to query some fields from the related field on Task (WhatId), this can't be directly done because a What refers to multiple objects. Polymorphic SOQL is possible in winter 13 release, check that out here 

 

http://blogs.developerforce.com/tech-pubs/2012/09/soql-polymorphism-or-how-i-learned-to-love-the-polymorphic-relationship.html