function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
derrickmorinderrickmorin 

Retrieving Tasks associated with Leads

I am looking at the API documentation and I am not seeing how Leads and Tasks are related.  I know that they are because on SF.com I can associate Tasks with Leads.  I want to query the web service api and retrieve all new tasks created in the past month and the Leads they are associated with.  All I am seeing is Task.AccountId and that doesn't seem to contain anything for Tasks that are associated with Leads.

Thanks

Derrick

benjasikbenjasik
The WhoId on Task can be a reference to either a Contact or a Lead. You can determine what a foreign key points to by the first three characters (the keyPrefix). The DescribeSObject call returns the keyPrefix for a given entity.

So get back all the tasks, iterate through them building up an array of WhoIds where the key starts with 00Q, then make a retrieve call on Lead with these ids.
_dj_dj

I've WhoIds that starts with '000' e.g. 000000000000000AAA

what does this mean?