I have below code in my Trigger which is trying to assign a Task to a Queue. I have provided access to Task object to the Queue. Below code works in anonymous window, it works when I create a Task in Anonymous window. However, automated test and apex trigger is giving me below error:
System.DmlException: Update failed. First exception on row 0 with id a0902000000Br9zAAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FinancialAccountTrigger: execution of AfterUpdate
caused by: LoggedException: Error while inserting task id: null Message: Assigned To ID: id value of incorrect type: 00G0f000005n0paEAA
Group accountHoldTaskOwner = [Select id from Group Where DeveloperName = 'Account_Team' AND Type = 'Queue' LIMIT 1]
Task t = new Task();
t.WhatId = account.id;
t.Status = 'Open';
t.Subject = 'Follow up with Customer';
t.Description = 'Follow up with Customer';
t.ActivityDate = Date.today().addDays(2);
t.OwnerId = accountHoldTaskOwner.Id;
Database.insert(t, true);