I Do'nt know why you want this on trigger, but still this is how you can get them for leads inserted,
Debug statement will give you Lead id and its related Open activities.
trigger OpenActivity_On_Lead on Lead (after Insert) { Set<Id> LeadIdSet = New Set<Id>(); Map<Id,List<OpenActivity>> MapOpentask = New Map<Id,List<OpenActivity>>(); Map<Id,List<Event>> MapOpenEvent = New Map<Id,List<Event>>();
for(Lead LeaObj:trigger.new){ LeadIdSet.add(LeaObj.Id); } for(Lead LeaObj:[Select id ,(Select ID , ActivityType ,whoId from OpenActivities) from Lead where ID IN:LeadIdSet]){ MapOpentask.put(LeaObj.id,LeaObj.OpenActivities); } System.debug('** Open Activiteies of Leads'+MapOpentask); }
Mark this as answer if it helps you so that others can benifit from this too.
Below given wil put you in the right direction.
Trigger openLead on Lead(after insert)
{
set<id> ids=new set<id>();
for(lead l:trigger.new)
{
ids.add(l.id);
}
for(lead l:select id ,leadstatus from lead where id in:ids] )
{
// do you logic here
}
}
I Do'nt know why you want this on trigger, but still this is how you can get them for leads inserted,
Debug statement will give you Lead id and its related Open activities.
trigger OpenActivity_On_Lead on Lead (after Insert) {
Set<Id> LeadIdSet = New Set<Id>();
Map<Id,List<OpenActivity>> MapOpentask = New Map<Id,List<OpenActivity>>();
Map<Id,List<Event>> MapOpenEvent = New Map<Id,List<Event>>();
for(Lead LeaObj:trigger.new){
LeadIdSet.add(LeaObj.Id);
}
for(Lead LeaObj:[Select id ,(Select ID , ActivityType ,whoId from OpenActivities) from Lead where ID IN:LeadIdSet]){
MapOpentask.put(LeaObj.id,LeaObj.OpenActivities);
}
System.debug('** Open Activiteies of Leads'+MapOpentask);
}
Mark this as answer if it helps you so that others can benifit from this too.