I am stuck with a bit of code - is someone able to help with this? For the 8th line of code, I'm getting a variable doesn't exist error. I have been starting at this far too long, so cannot see what's wrong.
EDIT: I have now updated my code, and now I am getting another error for: leadsToUpdateById.put(tmpLead);
it says incorrect signature.
public static void copyFirstCallDate(List triggerNew) {
Map<Task,Id> leadIdsByTasks = new Map<Task,Id>();
for (Task t : triggerNew) {
if (t.Status == 'Completed') {
leadIdsByTasks.put(t, t.WhoId);
}
}
Map<Id,Lead> leadsToUpdateById = new Map<Id,Lead>([SELECT Id, X1st_Call__c FROM Lead WHERE Id IN: leadIdsByTasks.values()]);
for (Task t : triggerNew) {
if (leadIdsByTasks.containsKey(t)) {
Id lId = leadIdsByTasks.get(t);
Lead tmpLead = leadsToUpdateById.get(lId);
tmpLead.X1st_Call__c = t.Closed_Date__c;
leadsToUpdateById.put(tmpLead);
}
}
if ( !leadsToUpdateById.values().isEmpty()) {
update leadsToUpdateById.values();
}
}
Tia