Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Try out the sample trigger given below :
trigger CopyLeadInformation on Task (before insert)
{
list<id> WhoIds = new list<id>();
for (Task t : trigger.new)
WhoIds.add(t.WhoId);
list<Lead> leadList = [select id,Company,Street,State,City,Phone,PostalCode from Lead where id in :WhoIds];
map<id, Lead> leadMap = new map<id, Lead>();
for(Lead l : leadList)
leadMap.put(l.id, l);
for (Task tsk : trigger.new)
system.debug('############3');
if (leadMap.containsKey(tsk.Whoid))
Lead l = leadMap.get(tsk.Whoid);
system.debug('>>>>>>>>>>' +l.id);
tsk.Description = tsk.Description + '\n'+ l.Company + '\n' + l.Street +'\n'+
l.City + ', ' + l.State + ' ' + l.PostalCode + '\n' + l.Phone;
system.debug('>>>>>>>>>>' + tsk.Description);
}
Hope this helps.
Try out the sample trigger given below :
trigger CopyLeadInformation on Task (before insert)
{
list<id> WhoIds = new list<id>();
for (Task t : trigger.new)
WhoIds.add(t.WhoId);
list<Lead> leadList = [select id,Company,Street,State,City,Phone,PostalCode from Lead where id in :WhoIds];
map<id, Lead> leadMap = new map<id, Lead>();
for(Lead l : leadList)
leadMap.put(l.id, l);
for (Task tsk : trigger.new)
{
system.debug('############3');
if (leadMap.containsKey(tsk.Whoid))
{
Lead l = leadMap.get(tsk.Whoid);
system.debug('>>>>>>>>>>' +l.id);
tsk.Description = tsk.Description + '\n'+ l.Company + '\n' + l.Street +'\n'+
l.City + ', ' + l.State + ' ' + l.PostalCode + '\n' + l.Phone;
system.debug('>>>>>>>>>>' + tsk.Description);
}
}
}
Hope this helps.