4

I wrote a trigger on a custom object, that should be able to handle an user and a queue as owner. In oder to test this i wrote a simple test:

Group testGroup = new Group(Name = 'Queue', Type = 'Queue');
insert testGroup;

QueueSobject testQueue = new QueueSObject(QueueId = testGroup.Id, SobjectType = 'Lead');
System.runAs(new User(Id = UserInfo.getUserId())) {   
    insert testQueue;
}

Lead l = new Lead(OwnerId = testGroup.Id, LastName = 'test', Company = 'test');
insert l;

This works fine for a Lead, but when i tried to do the same with an Opportunity or a custom object and i got the following error:

INVALID_OPERATION, Queue not associated with this SObject type: []

I do not understand what is the difference between the lead and the other objects and i did not find examples other than for the lead.

2 Answers 2

2

Queues do not work with Opportunities. For a full list of supported sObjects, check out the documentation at http://na14.salesforce.com/help/doc/en/queues_overview.htm.

In short, you can use queues with:

  • Leads
  • Cases
  • Knowledge articles
  • Service contracts
  • Custom objects
3
  • Mike, thanks for pointing out that queues are not working with Opportunities. Do you have any Idea, why it would not work with a custom object either?
    – Klaus
    Commented Jul 23, 2013 at 10:36
  • How is your custom object defined? You should be able to just assign the queue to the OwnerID, unless it's the child in a Master-Detail.
    – Mike Chale
    Commented Jul 23, 2013 at 11:01
  • It is not in a Master-Detail-Relationship and i am able to make a queue the owner over the UI, but it is not working in the test.
    – Klaus
    Commented Jul 23, 2013 at 11:52
0

Since,

Queues are not supported for opportunity , why don't you use queues on leads as usual and have the lead converted to opportunity and it will have same owner as the lead owner. Hope this helps.

Thanks.

You must log in to answer this question.

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