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

jd123jd123

Hi 

 

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

HariDineshHariDinesh

Hi,

 

You can achieve this using Trigger.

 

Trigger createtask on contact(before insert,before update)
{
   List<task> lls = new List<task>();
   id usid = userinfo.getuserid();
   if(trigger.isinsert)
   {
    for(contact con : trigger.new)
    {
     task ts = new task(Whatid =con.Accountid, Ownerid = usid ,Subject ='Email',Priority='High',status='In Progress');
     lls.add(ts);
     }
   }
   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