I can assign a task to a queue and insert the task if I do it via the "Anonymous apex"; however, if I run the same code via a batch then it throws the following error message:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Assigned To ID: id value of incorrect type: 00G1l000002utScEAI: [OwnerId]
The code I am running:
fflib_ISObjectUnitOfWork uow = Application.uow.newInstance();
Group queue = [SELECT Id, Name FROM Group WHERE Type = 'Queue' AND Name = 'my Queue' LIMIT 1];
Task task = new Task(
Subject = 'Test task',
Priority = 'Hoog',
Status = 'Niet gestart',
WhoId = '0038E00001C80eEQAR',
OwnerId = queue.Id,
Description = 'Do something'
);
uow.registerNew(task);
uow.commitWork();
I can assign a task to a queue and insert the task if I do it via the "Anonymous apex"; however, if I run the same code via a batch then it throws the following error message:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Assigned To ID: id value of incorrect type: 00G1l000002utScEAI: [OwnerId]
The code I am running: