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

Writing to the Task's Assigned to Field

I have a trigger that inserts a new task to a custom object and one of the fields is the Assigned To field,  Is there a way that i can alter that field or is it READ ONLY.





Yes you can alter the Assigned To ID field in task.  Assigned To ID is a label and the OwnerId is the api name.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


I have tried to write to the Task's Assigned To Field label whose API name is Owner, but it seems it's readonly. I want the assigned to field label to reflect a salesforce user that the task belongs to. Here is my code snippet 

  String username = '';
              List<User> userList=[Select Id,Name,Email 
        	                                FROM User
        	                                WHERE Email=:username
        	                                Limit 1];
                       Task taskToAdd = new Task(Description = myPlainText,
                                 Priority = 'Normal',
                                 Status = 'Inbound Email',
                                 Subject = email.subject,
                                 IsReminderSet = true,
                                 ReminderDateTime =,

 Am I the one doing it wrong or there is a different field to be used in the Task object to reflect the saleforce user fullname that the task belongs to.