I was writing a Test class to test a scenario where the Case will be assigned to Queue. However when I am assigning a Case Object to a Queue I am getting this error- "INVALID_OPERATION, Queue not associated with this SObject type: []"

I have created a Group and also mapped it to Case Object using QueueSObject but still facing this error.

User currentTestUser = [Select id from User where id = : UserInfo.getUserId()];
Group testGroup = new Group(Name='testGroup',type='Queue');
insert testGroup;
    QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SobjectType = 'Case');
    insert testQueue;             
  • Are you getting error in this code block??
    – Pmanglani
    Commented Aug 30, 2020 at 13:53
  • Why are you creating a queue in your test? Doesn't it already exist? Commented Aug 31, 2020 at 1:35
  • Aside from the first line being irrelevant and wasteful, this approach should work.
    – Adrian Larson
    Commented Aug 31, 2020 at 12:43
  • When I am assigning this Queue to a case then I am getting this error @Pmanglani Commented Aug 31, 2020 at 13:07
  • Have you checked this one salesforce.stackexchange.com/a/33457/56744
    – Pmanglani
    Commented Aug 31, 2020 at 13:10


You must log in to answer this question.

Browse other questions tagged .