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
SFDC n12SFDC n12 

Task creation on contact in apex help

Hi ,

I want to create a task with the following info in my batch class , Please let me know how to do it



•Create a Task on the Contact with the following info -
1.    Subject = 'Bounceback Correction'
2.    Due Date = Today + 5
3.    Your assignment = 'Please update the email address for this Contact.'
4.    Owner = AE
5.    CreatedBy = Set it as test(user)
6.    Comment = 'The bounced email subject = ' + IndividualEmailResult.Subject


Thanks in Advance
Santosh SSantosh S
 
User-added image
Sample Trigger above

Hope this helps

SFDC n12SFDC n12
i want to handle it in my apex



can i use the following below


List<Task> tasks = new List<Task>();
        tasks.add(new Task(
          Due Date = Date.today()+5,
           Subject='Bounceback Correction',
            //WhatId = a.Id,
           OwnerId = UserInfo.getUserId(),
           Status='In Progress'));

      insert tasks;


sushant sussushant sus
you want to use batch class or after after creating a contact you wantto create task then you can write after insert trigger