I am trying to insert a QueueSObject in test class but getting the error

System.TypeException: DML operation INSERT not allowed on QueueSobject

This code was working before but started giving error recently:

Group g1 = new Group(Name='collection', type='Queue');
insert g1;
QueuesObject q1 = new QueueSObject(QueueID = g1.Id, SobjectType = 'Task');
insert q1;
Collections_Queue__c c1 = new Collections_Queue__c(Queue_ID__c = g1.Id);
insert c1;

Any thoughts are welcome. Thanks.

1 Answer 1


As of Summer ’20 and later, only authenticated internal and external users can access this object.

A queue is a Group whose Type is Queue. To create a Group, you must have the Manage Users permission. Refer this for more details

  • How can enable this setting for my User. Is it a Profile level or a user level? Commented Apr 27, 2021 at 9:03
  • It is available at profile level under Administrative Permissions.
    – Kalpana
    Commented Apr 27, 2021 at 12:39
  • Thanks, the code was running in a different profile context due to which error was occuring. Commented Apr 27, 2021 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .