2

I'm looking for a way to do a SOQL request to get a Task record, but I keep ending up with this error:

Error: Compile Error: No such column 'What' on entity 'Task'. 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. at line 59 column 25

The 'What' field is labeled as 'Related To' (it's a standard field of the Activity object).

Here's my request generating this error:

Task task = [SELECT Type FROM Task WHERE What = :this.person.Id];

Thanks for your solutions.

1
  • if techtrekker's answer worked for you please upvote it or select it as the selected answer if you are able to. Nov 23, 2012 at 22:32

2 Answers 2

4

The relationship is called What, to compare with the Id, use WhatId

Task task = [SELECT Type FROM Task WHERE WhatId = :this.person.Id];

You could also use

Task task = [SELECT Type FROM Task WHERE What.Id = :this.person.Id];
3
  • Thanks, it's working. Is it the same thing with RecordType ?
    – jpmonette
    Nov 23, 2012 at 22:20
  • Yes RecordTypeId or RecordType.Id Nov 23, 2012 at 22:32
  • 1
    To determine this in the future for any object or field try exploring the Salesforce schema with the Force.com explorer wiki.developerforce.com/page/ForceExplorer Nov 26, 2012 at 9:35
1

Take a look here as well - there were some updates in winter 13 that expanded this functionality: SOQL Polymorphism

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .