function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ankit Khurana24Ankit Khurana24 

how to create a task for loged in user on new contact creation.

 Whenever a new contact is created under an account, system should create a task for the loged in user and an email should go to the mail id of the contact




Please don't paste the same question in multiple Discussions.




You can achieve this using Trigger.


Trigger createtask on contact(before insert,before update)
   List<task> lls = new List<task>();
   id usid = userinfo.getuserid();
    for(contact con :
     task ts = new task(Whatid =con.Accountid, Ownerid = usid ,Subject ='Email',Priority='High',status='In Progress');
   insert lls;


Above trigger I tested, working fine and exactly suits your requirement.

If you have any custom fields mandatory in task object include those fields also