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
rohitash yadav 8rohitash yadav 8 

display List of Leads with call, task in Visualforce page

Hi,

I need to show a list of those leads in my visualforce page on which any task or call is created. I have wrote the following query but it is not working.

Select Id, Name from Lead where Id IN (SELECT Who.Id FROM Task where Who.Type='Lead') limit 10

Can anyone help me?

Thanks,
Rohitash
Sukesh Kumar 33Sukesh Kumar 33
Try the following code
List<Lead> lstLeadToDisplay = new List<Lead>();
Set<Id> setLeadId = new Set<Id>();

for(Task objTask :  [SELECT Who.Id FROM Task where Who.Type='Lead']) {

	setLeadId.add(objTask.Who.Id);
}

lstLeadToDisplay = [Select Id, Name from Lead where Id IN : setLeadId];