apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
913 stars 517 forks source link

error while creating tasks for queues #293

Closed marco10507 closed 3 years ago

marco10507 commented 4 years ago

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();
stohn777 commented 4 years ago

As long as unit tests are passing for Commons, AT4DX and their Samples (which I'd expect to be the case), I'm in support of the change.

daveespo commented 3 years ago

Per the comment on #294, all classes were updated to API 51