You need to sign in to do that
Don't have an account?
Lisa Horne 1
Apex trigger not working during data loader upload.
I need to alter my trigger to run on Batch jobs as well as when they are updated one at a time. Could someone help me do that? This trigger creates a task when a lead is created and the Lead Web Comment field is filled out.
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.Lead_Web_Comment__c != null)){
t = new Task();
t.OwnerId = l.OwnerId;
t.Subject = 'Lead Web Comment';
t.Priority = 'Normal';
t.Status = 'Completed';
t.Type = 'Lead Web Comment';
t.Description = l.Lead_Web_Comment__c;
t.ActivityDate = Date.today();
// t.CallDuration=0;
t.whoid=l.id;
lTask.add(t);
}
}
if(!lTask.IsEmpty())
insert t;
}
}
}
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.Lead_Web_Comment__c != null)){
t = new Task();
t.OwnerId = l.OwnerId;
t.Subject = 'Lead Web Comment';
t.Priority = 'Normal';
t.Status = 'Completed';
t.Type = 'Lead Web Comment';
t.Description = l.Lead_Web_Comment__c;
t.ActivityDate = Date.today();
// t.CallDuration=0;
t.whoid=l.id;
lTask.add(t);
}
}
if(!lTask.IsEmpty())
insert t;
}
}
}
if(!lTask.IsEmpty())
insert lTask;
}
All Answers
if(!lTask.IsEmpty())
insert lTask;
}