You need to sign in to do that
Don't have an account?
Yash Jagtap
Create task on leads with selected status using trigger.
trigger TaskOnLeadStatusTrigger on Lead (after insert, after update) { List<Task> taskList = new List<Task>(); // Add a task for each Lead. // Iterate over Leads those are inserted recently. for (Lead ld : Trigger.New) { // Add a task for this lead with selected status and subject = 'Lead status changed'. taskList.add(new Task(WhoId = ld.OwnerId, Subject='Lead status changed"'+ld.Status+'". Start the next process')); } if (taskList.size() > 0) insert taskList; }Why is it not working, my goal is to create a task on leads with selected status using trigger. with WhoId i am trying to link Ids.
As the WhoId can only refer to the Lead or Contact id, it can't be referred to the user record.
If you want to assign the lead owner the task please use task OwnerId