I need some assistance.
Aim : create a Trigger that creates a task from a lead record when certain criteria is met.
Lead criteria :
Object : lead RT: Registration lead Source : Property
Task criteria ;
Status : not started Priority : normal Subject : should be populated with lead source picklist value Type: action Owner : lead owner
This is my logic ( see below) however every-time I create a lead with the criteria listed above I am not getting a task being generated
Really looking forward to your help
trigger CreateTaskOnLead on Lead (after insert) {
List<Task> lTask = new List<Task>();
Task t;
if(Trigger.isAfter) {
if(Trigger.isInsert) {
for(Lead l: Trigger.new) {
if((l.LeadSource != null)&&(l.LeadSource == 'Property')){
t = new Task();
t.OwnerId = l.OwnerId;
t.Subject = 'Property';
t.Priority = 'Normal';
t.Status = 'Not Started';
t.Type = 'Action';
lTask.add(t);
}
}
if(!lTask.IsEmpty())
insert t;
}
}
}